def test_incomplete_album(self): items = [] items.append(_make_item("one", 1)) items.append(_make_item("three", 3)) info = AlbumInfo( artist="some artist", album="some album", tracks=_make_trackinfo(), va=False, album_id=None, artist_id=None ) self.assertNotEqual(match.distance(items, info), 0) # Make sure the distance is not too great self.assertTrue(match.distance(items, info) < 0.2)
def test_incomplete_album(self): items = [] items.append(self.item('one', 1)) items.append(self.item('three', 3)) info = AlbumInfo( artist = 'some artist', album = 'some album', tracks = self.trackinfo(), va = False, album_id = None, artist_id = None, ) self.assertNotEqual(match.distance(items, info), 0) # Make sure the distance is not too great self.assertTrue(match.distance(items, info) < 0.2)
def test_incomplete_album(self): items = [] items.append(_make_item('one', 1)) items.append(_make_item('three', 3)) info = AlbumInfo( artist = 'some artist', album = 'some album', tracks = _make_trackinfo(), va = False, album_id = None, artist_id = None, ) self.assertNotEqual(match.distance(items, info), 0) # Make sure the distance is not too great self.assertTrue(match.distance(items, info) < 0.2)
def test_global_artists_differ(self): items = [] items.append(_make_item("one", 1)) items.append(_make_item("two", 2)) items.append(_make_item("three", 3)) info = AlbumInfo( artist="someone else", album="some album", tracks=_make_trackinfo(), va=False, album_id=None, artist_id=None ) self.assertNotEqual(match.distance(items, info), 0)
def test_comp_track_artists_do_not_match(self): items = [] items.append(_make_item("one", 1)) items.append(_make_item("two", 2, "someone else")) items.append(_make_item("three", 3)) info = AlbumInfo( artist="some artist", album="some album", tracks=_make_trackinfo(), va=True, album_id=None, artist_id=None ) self.assertNotEqual(match.distance(items, info), 0)
def _show_change(self, items=None, info=None, cur_artist=u"the artist", cur_album=u"the album", dist=0.1): items = items or self.items info = info or self.info mapping = dict(zip(items, info.tracks)) config["color"] = False album_dist = distance(items, info, mapping) album_dist._penalties = {"album": [dist]} commands.show_change(cur_artist, cur_album, autotag.AlbumMatch(album_dist, info, mapping, set(), set())) return self.io.getoutput().lower()
def test_tracks_out_of_order(self): items = [] items.append(_make_item("one", 1)) items.append(_make_item("three", 2)) items.append(_make_item("two", 3)) info = AlbumInfo( artist="some artist", album="some album", tracks=_make_trackinfo(), va=False, album_id=None, artist_id=None ) dist = match.distance(items, info) self.assertTrue(0 < dist < 0.2)
def _show_change(self, items=None, info=None, cur_artist="the artist", cur_album="the album", dist=0.1): """Return an unicode string representing the changes""" items = items or self.items info = info or self.info mapping = dict(zip(items, info.tracks)) config["ui"]["color"] = False album_dist = distance(items, info, mapping) album_dist._penalties = {"album": [dist]} commands.show_change(cur_artist, cur_album, autotag.AlbumMatch(album_dist, info, mapping, set(), set())) # FIXME decoding shouldn't be done here return self.io.getoutput().lower().decode("utf8")
def test_comp_track_artists_do_not_match(self): items = [] items.append(_make_item('one', 1)) items.append(_make_item('two', 2, 'someone else')) items.append(_make_item('three', 3)) info = AlbumInfo( artist = 'some artist', album = 'some album', tracks = _make_trackinfo(), va = True, album_id = None, artist_id = None, ) self.assertNotEqual(match.distance(items, info), 0)
def test_comp_track_artists_match(self): items = [] items.append(_make_item('one', 1)) items.append(_make_item('two', 2)) items.append(_make_item('three', 3)) info = AlbumInfo( artist = 'should be ignored', album = 'some album', tracks = _make_trackinfo(), va = True, album_id = None, artist_id = None, ) self.assertEqual(match.distance(items, info), 0)
def test_global_artists_differ(self): items = [] items.append(_make_item('one', 1)) items.append(_make_item('two', 2)) items.append(_make_item('three', 3)) info = AlbumInfo( artist = 'someone else', album = 'some album', tracks = _make_trackinfo(), va = False, album_id = None, artist_id = None, ) self.assertNotEqual(match.distance(items, info), 0)
def test_identical_albums(self): items = [] items.append(self.item('one', 1)) items.append(self.item('two', 2)) items.append(self.item('three', 3)) info = AlbumInfo( artist = 'some artist', album = 'some album', tracks = self.trackinfo(), va = False, album_id = None, artist_id = None, ) self.assertEqual(match.distance(items, info), 0)
def test_per_medium_track_numbers(self): items = [] items.append(_make_item("one", 1)) items.append(_make_item("two", 2)) items.append(_make_item("three", 1)) info = AlbumInfo( artist="some artist", album="some album", tracks=_make_trackinfo(), va=False, album_id=None, artist_id=None ) info.tracks[0].medium_index = 1 info.tracks[1].medium_index = 2 info.tracks[2].medium_index = 1 dist = match.distance(items, info) self.assertEqual(dist, 0)
def test_comp_track_artists_match(self): items = [] items.append(_make_item("one", 1)) items.append(_make_item("two", 2)) items.append(_make_item("three", 3)) info = AlbumInfo( artist="should be ignored", album="some album", tracks=_make_trackinfo(), va=True, album_id=None, artist_id=None, ) self.assertEqual(match.distance(items, info), 0)
def test_identical_albums(self): items = [] items.append(self.item('one', 1)) items.append(self.item('two', 2)) items.append(self.item('three', 3)) info = AlbumInfo( artist='some artist', album='some album', tracks=self.trackinfo(), va=False, album_id=None, artist_id=None, ) self.assertEqual(match.distance(items, info), 0)
def test_tracks_out_of_order(self): items = [] items.append(_make_item('one', 1)) items.append(_make_item('three', 2)) items.append(_make_item('two', 3)) info = AlbumInfo( artist = 'some artist', album = 'some album', tracks = _make_trackinfo(), va = False, album_id = None, artist_id = None, ) dist = match.distance(items, info) self.assertTrue(0 < dist < 0.2)
def _show_change(self, items=None, info=None, cur_artist=u'the artist', cur_album=u'the album', dist=0.1): items = items or self.items info = info or self.info mapping = dict(zip(items, info.tracks)) config['color'] = False album_dist = distance(items, info, mapping) album_dist._penalties = {'album': [dist]} commands.show_change( cur_artist, cur_album, autotag.AlbumMatch(album_dist, info, mapping, set(), set()), ) return self.io.getoutput().lower()
def test_two_medium_release(self): items = [] items.append(_make_item('one', 1)) items.append(_make_item('two', 2)) items.append(_make_item('three', 3)) info = AlbumInfo( artist = 'some artist', album = 'some album', tracks = _make_trackinfo(), va = False, album_id = None, artist_id = None, ) info.tracks[0].medium_index = 1 info.tracks[1].medium_index = 2 info.tracks[2].medium_index = 1 dist = match.distance(items, info) self.assertEqual(dist, 0)
def test_comp_no_track_artists(self): # Some VA releases don't have track artists (incomplete metadata). items = [] items.append(_make_item('one', 1)) items.append(_make_item('two', 2)) items.append(_make_item('three', 3)) info = AlbumInfo( artist = 'should be ignored', album = 'some album', tracks = _make_trackinfo(), va = True, album_id = None, artist_id = None, ) info.tracks[0].artist = None info.tracks[1].artist = None info.tracks[2].artist = None self.assertEqual(match.distance(items, info), 0)
def _show_change(self, items=None, info=None, cur_artist=u'the artist', cur_album=u'the album', dist=0.1): """Return an unicode string representing the changes""" items = items or self.items info = info or self.info mapping = dict(zip(items, info.tracks)) config['ui']['color'] = False album_dist = distance(items, info, mapping) album_dist._penalties = {'album': [dist]} commands.show_change( cur_artist, cur_album, autotag.AlbumMatch(album_dist, info, mapping, set(), set()), ) # FIXME decoding shouldn't be done here return util.text_string(self.io.getoutput().lower())
def _show_change(self, items=None, info=None, cur_artist=u'the artist', cur_album=u'the album', dist=0.1): """Return an unicode string representing the changes""" items = items or self.items info = info or self.info mapping = dict(zip(items, info.tracks)) config['ui']['color'] = False album_dist = distance(items, info, mapping) album_dist._penalties = {'album': [dist]} commands.show_change( cur_artist, cur_album, autotag.AlbumMatch(album_dist, info, mapping, set(), set()), ) # FIXME decoding shouldn't be done here return self.io.getoutput().lower().decode('utf8')
def test_per_medium_track_numbers(self): items = [] items.append(_make_item('one', 1)) items.append(_make_item('two', 2)) items.append(_make_item('three', 1)) info = AlbumInfo( artist = 'some artist', album = 'some album', tracks = _make_trackinfo(), va = False, album_id = None, artist_id = None, ) info.tracks[0].medium_index = 1 info.tracks[1].medium_index = 2 info.tracks[2].medium_index = 1 dist = match.distance(items, info) self.assertEqual(dist, 0)
def _dist(self, items, info): return match.distance(items, info, self._mapping(items, info))