added tests for page selection
This commit is contained in:
parent
0a7dfeb5ea
commit
6c89aabbb5
@ -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,7 +116,8 @@ class Search:
|
|||||||
|
|
||||||
self._current_option: MultiPageOptions = self.next_options
|
self._current_option: MultiPageOptions = self.next_options
|
||||||
|
|
||||||
self.search(query)
|
if not dry:
|
||||||
|
self.search(query)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def next_options(self) -> MultiPageOptions:
|
def next_options(self) -> MultiPageOptions:
|
||||||
|
52
src/tests/test_download.py
Normal file
52
src/tests/test_download.py
Normal 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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user