diff --git a/src/music_kraken/pages/download_center/search.py b/src/music_kraken/pages/download_center/search.py index 382946a..0a36f57 100644 --- a/src/music_kraken/pages/download_center/search.py +++ b/src/music_kraken/pages/download_center/search.py @@ -89,7 +89,8 @@ class Search: exclude_pages: Set[Type[Page]] = set(), exclude_shady: bool = False, max_displayed_options: int = 10, - option_digits: int = 3 + option_digits: int = 3, + dry: bool = False, ) -> None: _page_list: List[Type[Page]] = [] _audio_page_list: List[Type[Page]] = [] @@ -115,7 +116,8 @@ class Search: self._current_option: MultiPageOptions = self.next_options - self.search(query) + if not dry: + self.search(query) @property def next_options(self) -> MultiPageOptions: diff --git a/src/tests/test_download.py b/src/tests/test_download.py new file mode 100644 index 0000000..8768998 --- /dev/null +++ b/src/tests/test_download.py @@ -0,0 +1,52 @@ +import sys +import os +import unittest + +# Add the parent directory of the src package to the Python module search path +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from music_kraken import pages +from music_kraken.pages import download_center +from music_kraken.pages.download_center import page_attributes + +class TestPageSelection(unittest.TestCase): + def test_no_shady_pages(self): + search = download_center.Search( + "Hello World", + exclude_shady=True, + dry=True + ) + + for page in search.pages: + self.assertNotIn(page, page_attributes.SHADY_PAGES) + + def test_excluding(self): + search = download_center.Search( + "Hello World", + exclude_pages=set((pages.EncyclopaediaMetallum,)), + dry=True + ) + + for page in search.pages: + self.assertNotEqual(page, pages.EncyclopaediaMetallum) + + + def test_audio_one(self): + search = download_center.Search( + "Hello World", + exclude_shady=True, + dry=True + ) + + for audio_page in search.audio_pages: + self.assertIn(audio_page, page_attributes.AUDIO_PAGES) + + def test_audio_two(self): + search = download_center.Search( + "Hello World", + dry=True + ) + + for audio_page in search.audio_pages: + self.assertIn(audio_page, page_attributes.AUDIO_PAGES) + + \ No newline at end of file