class ApplyCompilationTest(_common.TestCase, ApplyTestUtil): def setUp(self): super(ApplyCompilationTest, self).setUp() self.items = [] self.items.append(Item({})) self.items.append(Item({})) trackinfo = [] trackinfo.append( TrackInfo( title=u'oneNew', track_id=u'dfa939ec-118c-4d0f-84a0-60f3d1e6522c', artist=u'artistOneNew', artist_id=u'a05686fc-9db2-4c23-b99e-77f5db3e5282', index=1, )) trackinfo.append( TrackInfo( title=u'twoNew', track_id=u'40130ed1-a27c-42fd-a328-1ebefb6caef4', artist=u'artistTwoNew', artist_id=u'80b3cf5e-18fe-4c59-98c7-e5bb87210710', index=2, )) self.info = AlbumInfo( tracks=trackinfo, artist=u'variousNew', album=u'albumNew', album_id='3b69ea40-39b8-487f-8818-04b6eff8c21a', artist_id='89ad4ac3-39f7-470e-963a-56509c546377', albumtype=u'compilation', ) def test_album_and_track_artists_separate(self): self._apply() self.assertEqual(self.items[0].artist, 'artistOneNew') self.assertEqual(self.items[1].artist, 'artistTwoNew') self.assertEqual(self.items[0].albumartist, 'variousNew') self.assertEqual(self.items[1].albumartist, 'variousNew') def test_mb_albumartistid_applied(self): self._apply() self.assertEqual(self.items[0].mb_albumartistid, '89ad4ac3-39f7-470e-963a-56509c546377') self.assertEqual(self.items[1].mb_albumartistid, '89ad4ac3-39f7-470e-963a-56509c546377') self.assertEqual(self.items[0].mb_artistid, 'a05686fc-9db2-4c23-b99e-77f5db3e5282') self.assertEqual(self.items[1].mb_artistid, '80b3cf5e-18fe-4c59-98c7-e5bb87210710') def test_va_flag_cleared_does_not_set_comp(self): self._apply() self.assertFalse(self.items[0].comp) self.assertFalse(self.items[1].comp) def test_va_flag_sets_comp(self): va_info = self.info.copy() va_info.va = True self._apply(info=va_info) self.assertTrue(self.items[0].comp) self.assertTrue(self.items[1].comp)
class ApplyTest(_common.TestCase, ApplyTestUtil): def setUp(self): super(ApplyTest, self).setUp() self.items = [] self.items.append(Item({})) self.items.append(Item({})) trackinfo = [] trackinfo.append( TrackInfo( title=u'oneNew', track_id=u'dfa939ec-118c-4d0f-84a0-60f3d1e6522c', medium=1, medium_index=1, medium_total=1, index=1, artist_credit='trackArtistCredit', artist_sort='trackArtistSort', )) trackinfo.append( TrackInfo( title=u'twoNew', track_id=u'40130ed1-a27c-42fd-a328-1ebefb6caef4', medium=2, medium_index=1, index=2, medium_total=1, )) self.info = AlbumInfo( tracks=trackinfo, artist=u'artistNew', album=u'albumNew', album_id='7edb51cb-77d6-4416-a23c-3a8c2994a2c7', artist_id='a6623d39-2d8e-4f70-8242-0a9553b91e50', artist_credit=u'albumArtistCredit', artist_sort=u'albumArtistSort', albumtype=u'album', va=False, mediums=2, ) def test_titles_applied(self): self._apply() self.assertEqual(self.items[0].title, 'oneNew') self.assertEqual(self.items[1].title, 'twoNew') def test_album_and_artist_applied_to_all(self): self._apply() self.assertEqual(self.items[0].album, 'albumNew') self.assertEqual(self.items[1].album, 'albumNew') self.assertEqual(self.items[0].artist, 'artistNew') self.assertEqual(self.items[1].artist, 'artistNew') def test_track_index_applied(self): self._apply() self.assertEqual(self.items[0].track, 1) self.assertEqual(self.items[1].track, 2) def test_track_total_applied(self): self._apply() self.assertEqual(self.items[0].tracktotal, 2) self.assertEqual(self.items[1].tracktotal, 2) def test_disc_index_applied(self): self._apply() self.assertEqual(self.items[0].disc, 1) self.assertEqual(self.items[1].disc, 2) def test_disc_total_applied(self): self._apply() self.assertEqual(self.items[0].disctotal, 2) self.assertEqual(self.items[1].disctotal, 2) def test_per_disc_numbering(self): self._apply(per_disc_numbering=True) self.assertEqual(self.items[0].track, 1) self.assertEqual(self.items[1].track, 1) def test_per_disc_numbering_track_total(self): self._apply(per_disc_numbering=True) self.assertEqual(self.items[0].tracktotal, 1) self.assertEqual(self.items[1].tracktotal, 1) def test_artist_credit(self): self._apply(artist_credit=True) self.assertEqual(self.items[0].artist, 'trackArtistCredit') self.assertEqual(self.items[1].artist, 'albumArtistCredit') self.assertEqual(self.items[0].albumartist, 'albumArtistCredit') self.assertEqual(self.items[1].albumartist, 'albumArtistCredit') def test_artist_credit_prefers_artist_over_albumartist_credit(self): self.info.tracks[0].artist = 'oldArtist' self.info.tracks[0].artist_credit = None self._apply(artist_credit=True) self.assertEqual(self.items[0].artist, 'oldArtist') def test_artist_credit_falls_back_to_albumartist(self): self.info.artist_credit = None self._apply(artist_credit=True) self.assertEqual(self.items[1].artist, 'artistNew') def test_mb_trackid_applied(self): self._apply() self.assertEqual(self.items[0].mb_trackid, 'dfa939ec-118c-4d0f-84a0-60f3d1e6522c') self.assertEqual(self.items[1].mb_trackid, '40130ed1-a27c-42fd-a328-1ebefb6caef4') def test_mb_albumid_and_artistid_applied(self): self._apply() for item in self.items: self.assertEqual(item.mb_albumid, '7edb51cb-77d6-4416-a23c-3a8c2994a2c7') self.assertEqual(item.mb_artistid, 'a6623d39-2d8e-4f70-8242-0a9553b91e50') def test_albumtype_applied(self): self._apply() self.assertEqual(self.items[0].albumtype, 'album') self.assertEqual(self.items[1].albumtype, 'album') def test_album_artist_overrides_empty_track_artist(self): my_info = self.info.copy() self._apply(info=my_info) self.assertEqual(self.items[0].artist, 'artistNew') self.assertEqual(self.items[1].artist, 'artistNew') def test_album_artist_overridden_by_nonempty_track_artist(self): my_info = self.info.copy() my_info.tracks[0].artist = 'artist1!' my_info.tracks[1].artist = 'artist2!' self._apply(info=my_info) self.assertEqual(self.items[0].artist, 'artist1!') self.assertEqual(self.items[1].artist, 'artist2!') def test_artist_credit_applied(self): self._apply() self.assertEqual(self.items[0].albumartist_credit, 'albumArtistCredit') self.assertEqual(self.items[0].artist_credit, 'trackArtistCredit') self.assertEqual(self.items[1].albumartist_credit, 'albumArtistCredit') self.assertEqual(self.items[1].artist_credit, 'albumArtistCredit') def test_artist_sort_applied(self): self._apply() self.assertEqual(self.items[0].albumartist_sort, 'albumArtistSort') self.assertEqual(self.items[0].artist_sort, 'trackArtistSort') self.assertEqual(self.items[1].albumartist_sort, 'albumArtistSort') self.assertEqual(self.items[1].artist_sort, 'albumArtistSort') def test_full_date_applied(self): my_info = self.info.copy() my_info.year = 2013 my_info.month = 12 my_info.day = 18 self._apply(info=my_info) self.assertEqual(self.items[0].year, 2013) self.assertEqual(self.items[0].month, 12) self.assertEqual(self.items[0].day, 18) def test_date_only_zeros_month_and_day(self): self.items = [] self.items.append(Item(year=1, month=2, day=3)) self.items.append(Item(year=4, month=5, day=6)) my_info = self.info.copy() my_info.year = 2013 self._apply(info=my_info) self.assertEqual(self.items[0].year, 2013) self.assertEqual(self.items[0].month, 0) self.assertEqual(self.items[0].day, 0) def test_missing_date_applies_nothing(self): self.items = [] self.items.append(Item(year=1, month=2, day=3)) self.items.append(Item(year=4, month=5, day=6)) self._apply() self.assertEqual(self.items[0].year, 1) self.assertEqual(self.items[0].month, 2) self.assertEqual(self.items[0].day, 3) def test_data_source_applied(self): my_info = self.info.copy() my_info.data_source = 'MusicBrainz' self._apply(info=my_info) self.assertEqual(self.items[0].data_source, 'MusicBrainz')