Debian Codegraph @

test/ui/test_ui_importer.py

raw
1 """Tests the TerminalImportSession. The tests are the same as in the
2
3 test_importer module. But here the test importer inherits from
4 ``TerminalImportSession``. So we test this class, too.
5 """
6
7 from unittest import mock
8
9 from beets import importer
10 from beets.test.helper import TerminalImportMixin
11 from test import test_importer
12
13
14 class TestNonAutotaggedImport(
15 TerminalImportMixin, test_importer.TestNonAutotaggedImport
16 ):
17 pass
18
19
20 class TestImport(TerminalImportMixin, test_importer.TestImport):
21 pass
22
23
24 class ImportSingletonTest(
25 TerminalImportMixin, test_importer.ImportSingletonTest
26 ):
27 def test_singleton_manual_search_updates_candidates(self):
28 self.importer.io.addinput("e")
29 self.importer.io.addinput("ManualArtist")
30 self.importer.io.addinput("ManualTrack")
31 self.importer.io.addinput("a")
32 self.importer.run()
33 assert not self.lib.albums()
34 assert self.lib.items().get().title == "ManualTrack"
35
36
37 class ImportTracksTest(TerminalImportMixin, test_importer.ImportTracksTest):
38 pass
39
40
41 class ImportCompilationTest(
42 TerminalImportMixin, test_importer.ImportCompilationTest
43 ):
44 pass
45
46
47 class ImportExistingTest(TerminalImportMixin, test_importer.ImportExistingTest):
48 pass
49
50
51 class ChooseCandidateTest(
52 TerminalImportMixin, test_importer.ChooseCandidateTest
53 ):
54 def test_manual_search_updates_candidates(self):
55 self.importer.io.addinput("e")
56 self.importer.io.addinput("ManualArtist")
57 self.importer.io.addinput("ManualAlbum")
58 self.importer.io.addinput("m")
59 self.importer.io.addinput("1")
60 self.importer.io.addinput("a")
61 self.importer.run()
62 album = self.lib.albums().get()
63 assert "ManualAlbum" in album.album
64
65 def test_manual_id_updates_candidates(self):
66 album_info = self.matcher._make_album_match("IDArtist", "IDAlbum", 1)
67 with mock.patch(
68 "beets.metadata_plugins.albums_for_ids", return_value=[album_info]
69 ):
70 self.importer.io.addinput("i")
71 self.importer.io.addinput("custom_release_id")
72 self.importer.io.addinput("m")
73 self.importer.io.addinput("1")
74 self.importer.io.addinput("a")
75 self.importer.run()
76 album = self.lib.albums().get()
77 assert "IDAlbum" in album.album
78
79
80 class GroupAlbumsImportTest(
81 TerminalImportMixin, test_importer.GroupAlbumsImportTest
82 ):
83 pass
84
85
86 class GlobalGroupAlbumsImportTest(
87 TerminalImportMixin, test_importer.GlobalGroupAlbumsImportTest
88 ):
89 pass
90
91
92 class TestImportDuplicateAlbumUpgrade(
93 TerminalImportMixin, test_importer.TestImportDuplicateAlbumUpgrade
94 ):
95 def setup_beets(self):
96 super().setup_beets()
97 self.config["import"]["duplicate_action"] = "ask"
98 self.importer.add_duplicate_action(importer.DuplicateAction.UPGRADE)