mirror of
https://github.com/bellingcat/auto-archiver.git
synced 2026-06-08 03:18:28 +03:00
Merge branch 'main' into small_issues
# Conflicts: # src/auto_archiver/core/base_module.py # src/auto_archiver/utils/misc.py
This commit is contained in:
@@ -18,7 +18,7 @@ def wacz_enricher(setup_module, mock_binary_dependencies):
|
||||
"socks_proxy_port": None,
|
||||
"proxy_server": None,
|
||||
}
|
||||
wacz = setup_module("wacz_enricher", configs)
|
||||
wacz = setup_module("wacz_extractor_enricher", configs)
|
||||
return wacz
|
||||
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class TestGenericExtractor(TestExtractorBase):
|
||||
"twitter.com/bellingcat/status/123",
|
||||
"https://www.youtube.com/watch?v=1"
|
||||
])
|
||||
def test_download_nonexistend_media(self, make_item, url):
|
||||
def test_download_nonexistent_media(self, make_item, url):
|
||||
"""
|
||||
Test to make sure that the extractor doesn't break on non-existend posts/media
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ from auto_archiver.core import Metadata, Feeder
|
||||
def test_setup_without_sheet_and_sheet_id(setup_module, mocker):
|
||||
# Ensure setup() raises AssertionError if neither sheet nor sheet_id is set.
|
||||
mocker.patch("gspread.service_account")
|
||||
with pytest.raises(AssertionError):
|
||||
with pytest.raises(ValueError):
|
||||
setup_module(
|
||||
"gsheet_feeder",
|
||||
{"service_account": "dummy.json", "sheet": None, "sheet_id": None},
|
||||
|
||||
@@ -6,7 +6,9 @@ from auto_archiver.__main__ import main
|
||||
|
||||
@pytest.fixture
|
||||
def orchestration_file_path(tmp_path):
|
||||
return (tmp_path / "example_orch.yaml").as_posix()
|
||||
folder = tmp_path / "secrets"
|
||||
folder.mkdir(exist_ok=True)
|
||||
return (folder / "example_orch.yaml").as_posix()
|
||||
|
||||
@pytest.fixture
|
||||
def orchestration_file(orchestration_file_path):
|
||||
@@ -28,6 +30,7 @@ def autoarchiver(tmp_path, monkeypatch, request):
|
||||
logger.add(sys.stderr)
|
||||
|
||||
request.addfinalizer(cleanup)
|
||||
(tmp_path / "secrets").mkdir(exist_ok=True)
|
||||
|
||||
# change dir to tmp_path
|
||||
monkeypatch.chdir(tmp_path)
|
||||
@@ -66,6 +69,7 @@ def test_call_autoarchiver_main(caplog, monkeypatch, tmp_path):
|
||||
|
||||
# monkey patch to change the current working directory, so that we don't use the user's real config file
|
||||
monkeypatch.chdir(tmp_path)
|
||||
(tmp_path / "secrets").mkdir(exist_ok=True)
|
||||
with monkeypatch.context() as m:
|
||||
m.setattr(sys, "argv", ["auto-archiver"])
|
||||
with pytest.raises(SystemExit):
|
||||
|
||||
@@ -4,7 +4,7 @@ from argparse import ArgumentParser, ArgumentTypeError
|
||||
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 import Metadata
|
||||
|
||||
TEST_ORCHESTRATION = "tests/data/test_orchestration.yaml"
|
||||
TEST_MODULES = "tests/data/test_modules/"
|
||||
@@ -160,4 +160,26 @@ def test_load_settings_for_module_from_commandline(orchestrator, test_args):
|
||||
|
||||
assert len(orchestrator.feeders) == 1
|
||||
assert orchestrator.feeders[0].name == "gsheet_feeder"
|
||||
assert orchestrator.config['gsheet_feeder']['sheet_id'] == "123"
|
||||
assert orchestrator.config['gsheet_feeder']['sheet_id'] == "123"
|
||||
|
||||
|
||||
def test_multiple_orchestrator(test_args):
|
||||
|
||||
o1_args = test_args + ["--feeders", "gsheet_feeder", "--gsheet_feeder.service_account", "tests/data/test_service_account.json"]
|
||||
o1 = ArchivingOrchestrator()
|
||||
|
||||
with pytest.raises(ValueError) as exit_error:
|
||||
# this should fail because the gsheet_feeder requires a sheet_id / sheet
|
||||
o1.setup(o1_args)
|
||||
|
||||
|
||||
|
||||
o2_args = test_args + ["--feeders", "example_module"]
|
||||
o2 = ArchivingOrchestrator()
|
||||
o2.setup(o2_args)
|
||||
|
||||
assert o2.feeders[0].name == "example_module"
|
||||
|
||||
output: Metadata = list(o2.feed())
|
||||
assert len(output) == 1
|
||||
assert output[0].get_url() == "https://example.com"
|
||||
Reference in New Issue
Block a user