added tests for page selection

This commit is contained in:
Hellow2 2023-03-29 09:42:53 +02:00
parent 0a7dfeb5ea
commit 6c89aabbb5
2 changed files with 56 additions and 2 deletions

View File

@ -89,7 +89,8 @@ class Search:
exclude_pages: Set[Type[Page]] = set(), exclude_pages: Set[Type[Page]] = set(),
exclude_shady: bool = False, exclude_shady: bool = False,
max_displayed_options: int = 10, max_displayed_options: int = 10,
option_digits: int = 3 option_digits: int = 3,
dry: bool = False,
) -> None: ) -> None:
_page_list: List[Type[Page]] = [] _page_list: List[Type[Page]] = []
_audio_page_list: List[Type[Page]] = [] _audio_page_list: List[Type[Page]] = []
@ -115,6 +116,7 @@ class Search:
self._current_option: MultiPageOptions = self.next_options self._current_option: MultiPageOptions = self.next_options
if not dry:
self.search(query) self.search(query)
@property @property

View File

@ -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)