Skip to content

Commit

Permalink
test_determine_link
Browse files Browse the repository at this point in the history
  • Loading branch information
Audiosutras committed Nov 13, 2023
1 parent d3d3028 commit b4f842f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,29 @@ def test_determine_source(self, source, expected_dict, mocker):
)
assert ebook._determine_source() == expected_dict

@pytest.mark.parametrize(
"selected_result, expected_link",
[
({"link": "https://books.google.com"}, "https://books.google.com"),
({"link": "http://shady-books.google.com"}, "http://shady-books.google.com"),
(
{"link": "/md5/234890238402380423"},
f"{AnnasEbook._SOURCE_DICT[AnnasEbook._SOURCE_ANNAS].get("url")}/md5/234890238402380423"
)
]
)
def test_determine_link(self, selected_result, expected_link, mocker):
ebook = AnnasEbook(q=self.q, ext=self.ext, output_dir=self.output_dir)
mocker.patch.object(
ebook,
'_current_source',
AnnasEbook._current_source # _SOURCE_ANNAS
)
mocker.patch.object(
ebook,
'_selected_result',
selected_result
)
assert ebook._determine_link() == expected_link


0 comments on commit b4f842f

Please sign in to comment.