|
26 | 26 | from beets.dbcore import types
|
27 | 27 | from mediafile import MediaFile
|
28 | 28 | from beets.util import displayable_path, bytestring_path, syspath
|
| 29 | +from beets.plugins import MetadataSourcePlugin |
| 30 | +from beets.util.id_extractors import spotify_id_regex, deezer_id_regex, \ |
| 31 | + beatport_id_regex |
29 | 32 |
|
30 | 33 | from test.test_importer import ImportHelper, AutotagStub
|
31 | 34 | from test.test_ui_importer import TerminalImportSessionSetup
|
@@ -558,6 +561,69 @@ def foo(self, session, task):
|
558 | 561 | require=ANY)
|
559 | 562 |
|
560 | 563 |
|
| 564 | +class ParseSpotifyIDTest(unittest.TestCase): |
| 565 | + def test_parse_id_correct(self): |
| 566 | + id_string = "39WqpoPgZxygo6YQjehLJJ" |
| 567 | + out = MetadataSourcePlugin._get_id( |
| 568 | + "album", id_string, spotify_id_regex) |
| 569 | + self.assertEqual(out, id_string) |
| 570 | + |
| 571 | + def test_parse_id_non_id_returns_none(self): |
| 572 | + id_string = "blah blah" |
| 573 | + out = MetadataSourcePlugin._get_id( |
| 574 | + "album", id_string, spotify_id_regex) |
| 575 | + self.assertEqual(out, None) |
| 576 | + |
| 577 | + def test_parse_id_url_finds_id(self): |
| 578 | + id_string = "39WqpoPgZxygo6YQjehLJJ" |
| 579 | + id_url = "https://open.spotify.com/album/%s" % id_string |
| 580 | + out = MetadataSourcePlugin._get_id( |
| 581 | + "album", id_url, spotify_id_regex) |
| 582 | + self.assertEqual(out, id_string) |
| 583 | + |
| 584 | + |
| 585 | +class ParseDeezerIDTest(unittest.TestCase): |
| 586 | + def test_parse_id_correct(self): |
| 587 | + id_string = "176356382" |
| 588 | + out = MetadataSourcePlugin._get_id( |
| 589 | + "album", id_string, deezer_id_regex) |
| 590 | + self.assertEqual(out, id_string) |
| 591 | + |
| 592 | + def test_parse_id_non_id_returns_none(self): |
| 593 | + id_string = "blah blah" |
| 594 | + out = MetadataSourcePlugin._get_id( |
| 595 | + "album", id_string, deezer_id_regex) |
| 596 | + self.assertEqual(out, None) |
| 597 | + |
| 598 | + def test_parse_id_url_finds_id(self): |
| 599 | + id_string = "176356382" |
| 600 | + id_url = "https://www.deezer.com/album/%s" % id_string |
| 601 | + out = MetadataSourcePlugin._get_id( |
| 602 | + "album", id_url, deezer_id_regex) |
| 603 | + self.assertEqual(out, id_string) |
| 604 | + |
| 605 | + |
| 606 | +class ParseBeatportIDTest(unittest.TestCase): |
| 607 | + def test_parse_id_correct(self): |
| 608 | + id_string = "3089651" |
| 609 | + out = MetadataSourcePlugin._get_id( |
| 610 | + "album", id_string, beatport_id_regex) |
| 611 | + self.assertEqual(out, id_string) |
| 612 | + |
| 613 | + def test_parse_id_non_id_returns_none(self): |
| 614 | + id_string = "blah blah" |
| 615 | + out = MetadataSourcePlugin._get_id( |
| 616 | + "album", id_string, beatport_id_regex) |
| 617 | + self.assertEqual(out, None) |
| 618 | + |
| 619 | + def test_parse_id_url_finds_id(self): |
| 620 | + id_string = "3089651" |
| 621 | + id_url = "https://www.beatport.com/release/album-name/%s" % id_string |
| 622 | + out = MetadataSourcePlugin._get_id( |
| 623 | + "album", id_url, beatport_id_regex) |
| 624 | + self.assertEqual(out, id_string) |
| 625 | + |
| 626 | + |
561 | 627 | def suite():
|
562 | 628 | return unittest.TestLoader().loadTestsFromName(__name__)
|
563 | 629 |
|
|
0 commit comments