dosage/tests/test_scraper.py

35 lines
1 KiB
Python
Raw Normal View History

# SPDX-License-Identifier: MIT
2014-01-05 15:50:57 +00:00
# Copyright (C) 2013-2014 Bastian Kleineidam
2022-06-04 08:56:25 +00:00
# Copyright (C) 2015-2022 Tobias Gruetzmacher
from pathlib import Path
import pytest
from dosagelib.scraper import scrapers
class TestScraper(object):
"""Test scraper module functions."""
def test_get_scrapers(self):
2022-06-04 08:56:25 +00:00
for scraperobj in scrapers.all():
scraperobj.indexes = ["bla"]
assert scraperobj.url, "missing url in %s" % scraperobj.name
def test_find_scrapers_single(self):
2022-06-04 08:56:25 +00:00
assert scrapers.find("xkcd")
def test_find_scrapers_multi(self):
2022-06-04 08:56:25 +00:00
with pytest.raises(ValueError, match='multiple comics found'):
scrapers.find("a")
def test_find_scrapers_error(self):
2020-04-18 11:03:02 +00:00
with pytest.raises(ValueError, match='empty comic name'):
scrapers.find('')
def test_user_dir(self):
2022-06-04 08:56:25 +00:00
oldlen = len(scrapers.all())
2021-01-19 00:19:07 +00:00
scrapers.adddir(Path(__file__).parent / 'mocks' / 'extra')
2022-06-04 08:56:25 +00:00
assert len(scrapers.all()) == oldlen + 1
assert scrapers.find('AnotherDummyTestScraper')