1 # -*- coding: utf-8 -*-
5 from sima.lib.track import Track
9 'albumartist': ['Devolt', 'Devolt Band'],
10 'albumartistsort': 'Devolt',
14 'file': 'music/Devolt/2011-Grey/03-Devolt - Crazy.mp3',
15 'last-modified': '2012-04-02T20:48:59Z',
16 'musicbrainz_albumartistid': 'd8e7e3e2-49ab-4f7c-b148-fc946d521f99',
17 'musicbrainz_albumid': 'ea2ef2cf-59e1-443a-817e-9066e3e0be4b',
18 'musicbrainz_artistid': 'd8e7e3e2-49ab-4f7c-b148-fc946d521f99',
19 'musicbrainz_trackid': 'fabf8fc9-2ae5-49c9-8214-a839c958d872',
21 'duration': '220.000',
26 class TestTrackObject(unittest.TestCase):
28 def test_tagcollapse(self):
30 self.assertTrue(trk.collapsed_tags, 'Should have collapsed a tag')
31 self.assertFalse(isinstance(trk.albumartist, list), 'Failed to collapse albumartist tag')
32 self.assertTrue(trk.Artist.name in DEVOLT.get('albumartist'),
33 'Failed to split multiple tag?')
35 def test_boolean_type(self):
36 self.assertFalse(bool(Track()))
37 for trk in [{}, {'artist': 'Devolt'}, {'artist': 'Devolt', 'file':''}]:
38 self.assertFalse(bool(Track(**trk)))
40 def test_albumartist(self):
41 trk = Track(albumartist='album_artist', artist='track_artist')
42 self.assertEqual(trk.Artist.name, 'album_artist')
43 trk = Track(artist='track_artist')
44 self.assertEqual(trk.Artist.name, 'track_artist')
46 def test_genres(self):
47 trk = Track(**{'artist': 'Devolt', 'genre': ['Rock, Stoner ', ' Punk; Heavy', 'doom']})
48 self.assertEqual(trk.genres, ['Rock', 'Stoner', 'Punk', 'Heavy', 'doom'])
49 trk = Track(**{'artist': 'Devolt', 'genre': [' Rock ', ' Stoner ', 'Punk ']})
50 self.assertEqual(trk.genres, ['Rock', 'Stoner', 'Punk'])
51 trk = Track(**{'artist': 'Devolt', 'genre': 'Punk '})
52 self.assertEqual(trk.genres, ['Punk'])
54 # vim: ai ts=4 sw=4 sts=4 expandtab