Fix tests
This commit is contained in:
parent
91b863fcb1
commit
005d7b72f4
@ -3,32 +3,30 @@ from __future__ import annotations
|
||||
import pytest
|
||||
|
||||
import comicapi.genericmetadata
|
||||
import comictalker.talkers.comicvine
|
||||
import testing.comicvine
|
||||
|
||||
|
||||
def test_search_for_series(comicvine_api, comic_cache):
|
||||
ct = comictalker.talkers.comicvine.ComicVineTalker("", "", 90, False, False, False)
|
||||
results = ct.search_for_series("cory doctorows futuristic tales of the here and now")
|
||||
cache_issues = comic_cache.get_search_results(ct.source_name, "cory doctorows futuristic tales of the here and now")
|
||||
results = comicvine_api.search_for_series("cory doctorows futuristic tales of the here and now")
|
||||
cache_issues = comic_cache.get_search_results(
|
||||
comicvine_api.source_name, "cory doctorows futuristic tales of the here and now"
|
||||
)
|
||||
assert results == cache_issues
|
||||
|
||||
|
||||
def test_fetch_volume_data(comicvine_api, comic_cache):
|
||||
ct = comictalker.talkers.comicvine.ComicVineTalker("", "", 90, False, False, False)
|
||||
result = ct.fetch_partial_volume_data(23437)
|
||||
result = comicvine_api.fetch_partial_volume_data(23437)
|
||||
del result["description"]
|
||||
del result["image_url"]
|
||||
cache_result = comic_cache.get_volume_info(23437, ct.source_name)
|
||||
cache_result = comic_cache.get_volume_info(23437, comicvine_api.source_name)
|
||||
del cache_result["description"]
|
||||
del cache_result["image_url"]
|
||||
assert result == cache_result
|
||||
|
||||
|
||||
def test_fetch_issues_by_volume(comicvine_api, comic_cache):
|
||||
ct = comictalker.talkers.comicvine.ComicVineTalker("", "", 90, False, False, False)
|
||||
results = ct.fetch_issues_by_volume(23437)
|
||||
cache_issues = comic_cache.get_volume_issues_info(23437, ct.source_name)
|
||||
results = comicvine_api.fetch_issues_by_volume(23437)
|
||||
cache_issues = comic_cache.get_volume_issues_info(23437, comicvine_api.source_name)
|
||||
for r in results:
|
||||
del r["volume"]
|
||||
del r["image_thumb_url"]
|
||||
@ -45,16 +43,14 @@ def test_fetch_issues_by_volume(comicvine_api, comic_cache):
|
||||
assert results == cache_issues
|
||||
|
||||
|
||||
def test_fetch_issue_data_by_issue_id(comicvine_api, settings, mock_version):
|
||||
ct = comictalker.talkers.comicvine.ComicVineTalker("", "", 90, False, False, False)
|
||||
result = ct.fetch_comic_data(140529)
|
||||
def test_fetch_issue_data_by_issue_id(comicvine_api):
|
||||
result = comicvine_api.fetch_comic_data(140529)
|
||||
result.notes = None
|
||||
assert result == testing.comicvine.cv_md
|
||||
|
||||
|
||||
def test_fetch_issues_by_volume_issue_num_and_year(comicvine_api):
|
||||
ct = comictalker.talkers.comicvine.ComicVineTalker("", "", 90, False, False, False)
|
||||
results = ct.fetch_issues_by_volume_issue_num_and_year([23437], "1", None)
|
||||
results = comicvine_api.fetch_issues_by_volume_issue_num_and_year([23437], "1", None)
|
||||
cv_expected = testing.comicvine.comic_issue_result.copy()
|
||||
testing.comicvine.filter_field_list(
|
||||
cv_expected,
|
||||
@ -82,8 +78,7 @@ cv_issue = [
|
||||
|
||||
|
||||
@pytest.mark.parametrize("volume_id, issue_number, expected", cv_issue)
|
||||
def test_fetch_issue_data(comicvine_api, settings, mock_version, volume_id, issue_number, expected):
|
||||
ct = comictalker.talkers.comicvine.ComicVineTalker("", "", 90, False, False, False)
|
||||
results = ct.fetch_issue_data(volume_id, issue_number)
|
||||
def test_fetch_issue_data(comicvine_api, volume_id, issue_number, expected):
|
||||
results = comicvine_api.fetch_issue_data(volume_id, issue_number)
|
||||
results.notes = None
|
||||
assert results == expected
|
||||
|
@ -54,7 +54,9 @@ def no_requests(monkeypatch) -> None:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def comicvine_api(monkeypatch, cbz, comic_cache) -> comictalker.talkers.comicvine.ComicVineTalker:
|
||||
def comicvine_api(
|
||||
monkeypatch, cbz, comic_cache, mock_version, settings
|
||||
) -> comictalker.talkers.comicvine.ComicVineTalker:
|
||||
# Any arguments may be passed and mock_get() will always return our
|
||||
# mocked object, which only has the .json() method or None for invalid urls.
|
||||
|
||||
@ -112,7 +114,14 @@ def comicvine_api(monkeypatch, cbz, comic_cache) -> comictalker.talkers.comicvin
|
||||
# apply the monkeypatch for requests.get to mock_get
|
||||
monkeypatch.setattr(requests, "get", m_get)
|
||||
|
||||
cv = comictalker.talkers.comicvine.ComicVineTalker("", "", 90, False, False, False)
|
||||
cv = comictalker.talkers.comicvine.ComicVineTalker(
|
||||
api_url="",
|
||||
api_key="",
|
||||
series_match_thresh=90,
|
||||
remove_html_tables=False,
|
||||
use_series_start_as_volume=False,
|
||||
wait_on_ratelimit=False,
|
||||
)
|
||||
return cv
|
||||
|
||||
|
||||
@ -125,6 +134,7 @@ def mock_version(monkeypatch):
|
||||
monkeypatch.setattr(comictaggerlib.ctversion, "__version__", version)
|
||||
monkeypatch.setattr(comictaggerlib.ctversion, "version_tuple", version_tuple)
|
||||
monkeypatch.setattr(comictaggerlib.ctversion, "__version_tuple__", version_tuple)
|
||||
yield (version, version_tuple)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
Loading…
x
Reference in New Issue
Block a user