Add tests for range of discogs id extraction
@@ -355,9 +355,28 @@ class DGAlbumInfoTest(_common.TestCase):
self.assertEqual(d, None)
self.assertIn('Release does not contain the required fields', logs[0])
+ def test_album_for_id(self):
+ """Test parsing for a valid Discogs release_id"""
+ test_patterns = [('http://www.discogs.com/G%C3%BCnther-Lause-Meru-Ep/release/4354798', 4354798), # NOQA E501
+ ('http://www.discogs.com/release/4354798-G%C3%BCnther-Lause-Meru-Ep', 4354798), # NOQA E501
+ ('http://www.discogs.com/G%C3%BCnther-4354798Lause-Meru-Ep/release/4354798', 4354798), # NOQA E501
+ ('http://www.discogs.com/release/4354798-G%C3%BCnther-4354798Lause-Meru-Ep/', 4354798), # NOQA E501
+ ('[r4354798]', 4354798),
+ ('r4354798', 4354798),
+ ('4354798', 4354798),
+ ('yet-another-metadata-provider.org/foo/12345', ''),
+ ('005b84a0-ecd6-39f1-b2f6-6eb48756b268', ''),
+ ]
+ for test_pattern, expected in test_patterns:
+ match = DiscogsPlugin().extract_release_id_regex(test_pattern)
+ if not match:
+ match = ''
+ self.assertEqual(match, expected)
+
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
+
if __name__ == '__main__':
unittest.main(defaultTest='suite')
