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, 'track_artist')
43 trk = Track(artist='track_artist')
44 self.assertEqual(trk.Artist.name, 'track_artist')
45 self.assertEqual(trk.Artist.albumartist, 'track_artist')
47 def test_genres(self):
48 trk = Track(**{'artist': 'Devolt', 'genre': ['Rock, Stoner ', ' Punk; Heavy', 'doom']})
49 self.assertEqual(trk.genres, ['Rock', 'Stoner', 'Punk', 'Heavy', 'doom'])
50 trk = Track(**{'artist': 'Devolt', 'genre': [' Rock ', ' Stoner ', 'Punk ']})
51 self.assertEqual(trk.genres, ['Rock', 'Stoner', 'Punk'])
52 trk = Track(**{'artist': 'Devolt', 'genre': 'Punk '})
53 self.assertEqual(trk.genres, ['Punk'])
55 def test_artist_object(self):
57 self.assertEqual(trk.Artist.name, DEVOLT['artist'])
58 self.assertEqual(trk.Artist.mbid, DEVOLT['musicbrainz_artistid'])
60 def test_album_object(self):
62 self.assertEqual(trk.Album.name, DEVOLT['album'])
63 self.assertEqual(trk.Album.mbid, DEVOLT['musicbrainz_albumid'])
65 # vim: ai ts=4 sw=4 sts=4 expandtab