summaryrefslogtreecommitdiffstatshomepage
path: root/tests/plugins/scrapers
diff options
context:
space:
mode:
authorWolfgang Müller2024-11-15 14:13:24 +0100
committerWolfgang Müller2024-11-15 14:13:24 +0100
commit9d27d52af9b852ac492f391fe69f5dd0a027c3cf (patch)
tree6adf0cfe3cc5f1b540361acb4324091370a5b628 /tests/plugins/scrapers
parent3b62b56c706622b7361e267d92f0408a29bee812 (diff)
downloadhircine-9d27d52af9b852ac492f391fe69f5dd0a027c3cf.tar.gz
backend/plugins: Throw error if E-Hentai response is missing 'gmetadata'
It might be that we get a valid (maybe empty) response from the API, in which case we do not want to simply crash because we expect the 'gmetadata' field in the response. Instead, throw a proper ScrapeError for it.
Diffstat (limited to '')
-rw-r--r--tests/plugins/scrapers/test_ehentai_api.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/plugins/scrapers/test_ehentai_api.py b/tests/plugins/scrapers/test_ehentai_api.py
index dd283e1..c746440 100644
--- a/tests/plugins/scrapers/test_ehentai_api.py
+++ b/tests/plugins/scrapers/test_ehentai_api.py
@@ -124,6 +124,22 @@ def test_raises_scrape_error_with_invalid_json(requests_mock, gen_comic):
assert set(scraper.collect()) == set()
+def test_raises_scrape_error_with_missing_field(requests_mock, gen_comic):
+ comic = next(gen_comic)
+ comic.url = "https://exhentai.org/g/1025913/fdaabef1a2"
+
+ scraper = ehentai_api.EHentaiAPIScraper(comic)
+
+ requests_mock.post(ehentai_api.API_URL, text="{}")
+
+ assert scraper.is_available
+ assert scraper.id == 1025913
+ assert scraper.token == "fdaabef1a2"
+
+ with pytest.raises(ScrapeError, match="Response is missing 'gmetadata' field"):
+ assert set(scraper.collect()) == set()
+
+
def test_raises_scrape_error_with_error_code(requests_mock, gen_comic):
comic = next(gen_comic)
comic.url = "https://exhentai.org/g/1025913/fdaabef1a2"