kopia lustrzana https://github.com/bellingcat/auto-archiver
Fix up unit tests - dataclass + subclasses not having @dataclass was breaking it
rodzic
b7d9145f6c
commit
fade68c6f4
|
@ -21,7 +21,6 @@ import re
|
|||
from ..core import Metadata, ArchivingContext, BaseModule
|
||||
|
||||
|
||||
@dataclass
|
||||
class Extractor(BaseModule):
|
||||
"""
|
||||
Base class for implementing extractors in the media archiving framework.
|
||||
|
|
|
@ -9,10 +9,11 @@ from pytwitter import Api
|
|||
from slugify import slugify
|
||||
|
||||
from auto_archiver.core import Extractor
|
||||
from auto_archiver.core import Metadata,Media
|
||||
from auto_archiver.core import Metadata, Media
|
||||
|
||||
class TwitterApiExtractor(Extractor):
|
||||
valid_url = re.compile(r"(?:twitter|x).com\/(?:\#!\/)?(\w+)\/status(?:es)?\/(\d+)")
|
||||
|
||||
valid_url: re.Pattern = re.compile(r"(?:twitter|x).com\/(?:\#!\/)?(\w+)\/status(?:es)?\/(\d+)")
|
||||
|
||||
def setup(self, config: dict) -> None:
|
||||
super().setup(config)
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
from typing import Type
|
||||
|
||||
import pytest
|
||||
|
||||
from auto_archiver.core.metadata import Metadata
|
||||
from auto_archiver.core.extractor import Extractor
|
||||
|
||||
|
||||
class TestExtractorBase(object):
|
||||
|
||||
extractor_module: str = None
|
||||
|
@ -13,7 +16,7 @@ class TestExtractorBase(object):
|
|||
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"
|
||||
|
||||
self.extractor: Extractor = setup_module(self.extractor_module, self.config)
|
||||
self.extractor: Type[Extractor] = setup_module(self.extractor_module, self.config)
|
||||
|
||||
def assertValidResponseMetadata(self, test_response: Metadata, title: str, timestamp: str, status: str = ""):
|
||||
assert test_response is not False
|
||||
|
|
|
@ -4,6 +4,7 @@ from argparse import ArgumentParser
|
|||
from auto_archiver.core.orchestrator import ArchivingOrchestrator
|
||||
from auto_archiver.version import __version__
|
||||
from auto_archiver.core.config import read_yaml, store_yaml
|
||||
from auto_archiver.core.module import _LAZY_LOADED_MODULES
|
||||
|
||||
TEST_ORCHESTRATION = "tests/data/test_orchestration.yaml"
|
||||
TEST_MODULES = "tests/data/test_modules/"
|
||||
|
@ -29,6 +30,10 @@ def orchestrator():
|
|||
if logger._core.handlers.get(1):
|
||||
logger.remove(1)
|
||||
|
||||
# delete out any loaded modules
|
||||
_LAZY_LOADED_MODULES.clear()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def basic_parser(orchestrator) -> ArgumentParser:
|
||||
return orchestrator.setup_basic_parser()
|
||||
|
|
Ładowanie…
Reference in New Issue