Exemple #1
0
 def test_parse_with_featuring(self):
     """Test parsing of a release with a featuring artists track."""
     data = {
         'id':
         123,
         'tracklist': [
             self._make_track('A',
                              '1',
                              '01:01',
                              extraartists=[{
                                  'name': 'ANOTHER ARTIST NAME',
                                  'id': 320,
                                  'role': 'Featuring'
                              }])
         ],
         'artists': [{
             'name': 'ARTIST NAME',
             'id': 321,
             'join': ''
         }],
         'title':
         'TITLE'
     }
     release = Bag(data=data,
                   title=data['title'],
                   artists=[Bag(data=d) for d in data['artists']])
     d = DiscogsPlugin().get_album_info(release)
     self.assertEqual(d.artist, 'ARTIST NAME')
     print(d.tracks[0])
     self.assertEqual(d.tracks[0].artist,
                      'ARTIST NAME feat. ANOTHER ARTIST NAME')
     self.assertEqual(d.album, 'TITLE')
     self.assertEqual(len(d.tracks), 1)
Exemple #2
0
    def test_get_track_from_album_by_title_approx(self):
        data = {'id': 123,
                'tracklist': [
                    self._make_track('SONG A', '1', '01:01'),
                    self._make_track('SONG B', '2', '02:02'),
                    self._make_track('COMPLETELY DIFFERENT', '3', '03:03'),
                ],
                'artists': [{'name': 'ARTIST NAME', 'id': 321, 'join': ''}],
                'title': 'TITLE'}
        release = Bag(data=data,
                      title=data['title'],
                      artists=[Bag(data=d) for d in data['artists']])

        d = DiscogsPlugin()
        album_info = d.get_album_info(release)
        track_list = d.get_tracks_from_album_by_title(album_info, 'SONG')

        self.assertEqual(len(track_list), 2)

        song_a = None
        song_b = None
        for track_info in track_list:
            if track_info.title == 'SONG A':
                song_a = track_info
            elif track_info.title == 'SONG B':
                song_b = track_info

        self.assertIsNotNone(song_a)
        self.assertIsNotNone(song_b)
        self.assertEqual(song_a.artist, 'ARTIST NAME')
        self.assertEqual(song_a.artist_id, 321)
        self.assertEqual(song_b.artist, 'ARTIST NAME')
        self.assertEqual(song_b.artist_id, 321)
Exemple #3
0
    def test_get_track_from_album_by_title_missing(self):
        data = {'id': 123,
                'tracklist': [self._make_track('SONG', '1', '01:01')],
                'artists': [{'name': 'ARTIST NAME', 'id': 321, 'join': ''}],
                'title': 'TITLE'}
        release = Bag(data=data,
                      title=data['title'],
                      artists=[Bag(data=d) for d in data['artists']])

        d = DiscogsPlugin()
        album_info = d.get_album_info(release)
        track_list = d.get_tracks_from_album_by_title(album_info, 'ZZZZZZZZ', 0.0)
        self.assertEqual(len(track_list), 0)
Exemple #4
0
    def test_get_track_from_album_by_position_missing(self):
        data = {'id': 123,
                'tracklist': [self._make_track('SONG', '1', '01:01')],
                'artists': [{'name': 'ARTIST NAME', 'id': 321, 'join': ''}],
                'title': 'TITLE'}
        release = Bag(data=data,
                      title=data['title'],
                      artists=[Bag(data=d) for d in data['artists']])

        d = DiscogsPlugin()
        album_info = d.get_album_info(release)
        track_info = d.get_track_from_album_by_position(album_info, '2')
        self.assertIsNone(track_info)
Exemple #5
0
 def test_parse_minimal_release(self):
     """Test parsing of a release with the minimal amount of information."""
     data = {'id': 123,
             'tracklist': [self._make_track('A', '1', '01:01')],
             'artists': [{'name': 'ARTIST NAME', 'id': 321, 'join': ''}],
             'title': 'TITLE'}
     release = Bag(data=data,
                   title=data['title'],
                   artists=[Bag(data=d) for d in data['artists']])
     d = DiscogsPlugin().get_album_info(release)
     self.assertEqual(d.artist, 'ARTIST NAME')
     self.assertEqual(d.album, 'TITLE')
     self.assertEqual(len(d.tracks), 1)
Exemple #6
0
    def test_parse_release_without_required_fields(self):
        """Test parsing of a release that does not have the required fields."""
        release = Bag(data={}, refresh=lambda *args: None)
        with capture_log() as logs:
            d = DiscogsPlugin().get_album_info(release)

        self.assertEqual(d, None)
        self.assertIn('Release does not contain the required fields', logs[0])
Exemple #7
0
    def _make_release(self, tracks=None):
        """Returns a Bag that mimics a discogs_client.Release. The list
        of elements on the returned Bag is incomplete, including just
        those required for the tests on this class."""
        data = {
            'id':
            'ALBUM ID',
            'uri':
            'https://www.discogs.com/release/release/13633721',
            'title':
            'ALBUM TITLE',
            'year':
            '3001',
            'artists': [{
                'name': 'ARTIST NAME',
                'id': 'ARTIST ID',
                'join': ','
            }],
            'formats': [{
                'descriptions': ['FORMAT DESC 1', 'FORMAT DESC 2'],
                'name': 'FORMAT',
                'qty': 1
            }],
            'styles': ['STYLE1', 'STYLE2'],
            'genres': ['GENRE1', 'GENRE2'],
            'labels': [{
                'name': 'LABEL NAME',
                'catno': 'CATALOG NUMBER',
            }],
            'tracklist': []
        }

        if tracks:
            for recording in tracks:
                data['tracklist'].append(recording)

        return Bag(
            data=data,
            # Make some fields available as properties, as they are
            # accessed by DiscogsPlugin methods.
            title=data['title'],
            artists=[Bag(data=d) for d in data['artists']])