-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_filename_parser.py
57 lines (46 loc) · 2.22 KB
/
test_filename_parser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from unittest import TestCase
from filename_parser import FilenameParser
CASES = [
# (filename,
# (label, artist, title)),
# 2 parts with spaces
('Abstr4ct - Hot Up.wav',
('', 'Abstr4ct', 'Hot Up')),
('Creatures - Swamp Martian (Original Mix).wav',
('', 'Creatures', 'Swamp Martian (Original Mix)')),
('T.R.A.C. - The Pursuit feat. Paul SG MC Conrad (Artificial Intelligence Remix).wav',
('', 'T.R.A.C.', 'The Pursuit feat. Paul SG & MC Conrad (Artificial Intelligence Remix)')),
('Unkoded - Wax It!!.wav',
('', 'Unkoded', 'Wax It!!')),
# 2 parts with spaces where artist contains a hyphen
('L-Side - Inna Di Dance.wav',
('', 'L-Side', 'Inna Di Dance')),
('A-Audio - Stop Right There.wav',
('', 'A-Audio', 'Stop Right There')),
# double-space implies missing ampersand
('Simplification nCamargo - Listen Up (Sl8r Remix).wav',
('', 'Simplification & nCamargo', 'Listen Up (Sl8r Remix)')),
# 2 parts but there is a track number
('01 Paul T Edward Oberon - For Our Love w Makoto Lorna King.wav',
('', 'Paul T & Edward Oberon', 'For Our Love w/Makoto & Lorna King')),
('L-Side GQ - Zaga Dan.wav',
('', 'L-Side & GQ', 'Zaga Dan')),
# looks like 3 parts, but actually the first part is a track number
('7 - Skoel Dreaman - Starting Point.wav',
('', 'Skoel & Dreaman', 'Starting Point')),
# 2 parts with underscores, but there is a catalogue number
('D9REC110_Quadrant_&_Iris_&_Jamal_-_Dial_Back_(Original_Mix).wav',
('D9REC110', 'Quadrant & Iris & Jamal', 'Dial Back (Original Mix)')),
('TRUST025_Trex_&_Benny_V_-_Tundra_(Myth_Remix).wav',
('TRUST025', 'Trex & Benny V', 'Tundra (Myth Remix)')),
# lonely 't' implies missing apostrophe
('BBEXCL25_Black_Barrel_-_Steal_Kill_But_Don_t_Mess_With_Drugs.wav',
('BBEXCL25', 'Black Barrel', 'Steal Kill But Don\'t Mess With Drugs')),
]
class FilenameParserTestCase(TestCase):
def test_filename_parsing(self):
for infile, label_artist_title in CASES:
with self.subTest(msg=infile):
fnp = FilenameParser(infile)
assert fnp.analyse()
assert (fnp.label, fnp.artist, fnp.title) == label_artist_title