auto-archiver/tests/extractors/test_extractor_base.py

28 wiersze
966 B
Python
Czysty Zwykły widok Historia

import pytest
2025-01-13 13:31:29 +00:00
from auto_archiver.core.metadata import Metadata
2025-01-28 13:40:12 +00:00
from auto_archiver.core.extractor import Extractor
2025-01-28 13:40:12 +00:00
class TestExtractorBase(object):
2025-01-28 13:40:12 +00:00
extractor_module: str = None
config: dict = None
@pytest.fixture(autouse=True)
2025-01-28 13:40:12 +00:00
def setup_archiver(self, setup_module):
assert self.extractor_module is not None, "self.extractor_module must be set on the subclass"
assert self.config is not None, "self.config must be a dict set on the subclass"
2025-01-28 13:40:12 +00:00
self.extractor: Extractor = setup_module(self.extractor_module, self.config)
2025-01-13 13:31:29 +00:00
def assertValidResponseMetadata(self, test_response: Metadata, title: str, timestamp: str, status: str = ""):
assert test_response is not False
if not status:
assert test_response.is_success()
else:
assert status == test_response.status
2025-01-13 12:15:13 +00:00
assert title == test_response.get_title()
assert timestamp, test_response.get("timestamp")