Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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()
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
 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")
Ejemplo n.º 9
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)
Ejemplo n.º 10
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)
Ejemplo n.º 11
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)
Ejemplo n.º 12
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)
Ejemplo n.º 13
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)
Ejemplo n.º 14
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)
Ejemplo n.º 15
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)
Ejemplo n.º 16
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)
Ejemplo n.º 17
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()
Ejemplo n.º 18
0
 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)
Ejemplo n.º 19
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)
Ejemplo n.º 20
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())
Ejemplo n.º 21
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 self.io.getoutput().lower().decode('utf8')
Ejemplo n.º 22
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)
Ejemplo n.º 23
0
 def _dist(self, items, info):
     return match.distance(items, info, self._mapping(items, info))