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',
25 class TestTrackObject(unittest.TestCase):
27 def test_tagcollapse(self):
29 self.assertTrue(trk.collapsed_tags, 'Should have collapsed a tag')
30 self.assertFalse(isinstance(trk.albumartist, list), 'Failed to collapse albumartist tag')
31 self.assertTrue(trk.Artist.name in DEVOLT.get('albumartist'),
32 'Failed to split multiple tag?')
34 def test_boolean_type(self):
35 self.assertFalse(bool(Track()))
36 for trk in [{}, {'artist': 'Devolt'}, {'artist': 'Devolt', 'file':''}]:
37 self.assertFalse(bool(Track(**trk)))
39 def test_albumartist(self):
40 trk = Track(albumartist='album_artist', artist='track_artist')
41 self.assertEqual(trk.Artist.name, 'album_artist')
42 trk = Track(artist='track_artist')
43 self.assertEqual(trk.Artist.name, 'track_artist')
45 def test_genres(self):
46 trk = Track(**{'artist': 'Devolt', 'genre': ['Rock, Stoner ', ' Punk; Heavy', 'doom']})
47 self.assertEqual(trk.genres, ['Rock', 'Stoner', 'Punk', 'Heavy', 'doom'])
48 trk = Track(**{'artist': 'Devolt', 'genre': [' Rock ', ' Stoner ', 'Punk ']})
49 self.assertEqual(trk.genres, ['Rock', 'Stoner', 'Punk'])
50 trk = Track(**{'artist': 'Devolt', 'genre': 'Punk '})
51 self.assertEqual(trk.genres, ['Punk'])
53 # vim: ai ts=4 sw=4 sts=4 expandtab