kopia lustrzana https://github.com/bellingcat/auto-archiver
Implementation tests for auto-archiver
rodzic
e9dd321dcd
commit
74207d7821
|
@ -111,7 +111,6 @@ class ArchivingOrchestrator:
|
||||||
# if full, we'll load all modules
|
# if full, we'll load all modules
|
||||||
# TODO: BUG** - basic_config won't have steps in it, since these args aren't added to 'basic_parser'
|
# TODO: BUG** - basic_config won't have steps in it, since these args aren't added to 'basic_parser'
|
||||||
# but should we add them? Or should we just add them to the 'complete' parser?
|
# but should we add them? Or should we just add them to the 'complete' parser?
|
||||||
|
|
||||||
if yaml_config != EMPTY_CONFIG:
|
if yaml_config != EMPTY_CONFIG:
|
||||||
# only load the modules enabled in config
|
# only load the modules enabled in config
|
||||||
# TODO: if some steps are empty (e.g. 'feeders' is empty), should we default to the 'simple' ones? Or only if they are ALL empty?
|
# TODO: if some steps are empty (e.g. 'feeders' is empty), should we default to the 'simple' ones? Or only if they are ALL empty?
|
||||||
|
@ -269,7 +268,6 @@ class ArchivingOrchestrator:
|
||||||
for module in modules_to_load:
|
for module in modules_to_load:
|
||||||
if module == 'cli_feeder':
|
if module == 'cli_feeder':
|
||||||
# pseudo module, don't load it
|
# pseudo module, don't load it
|
||||||
breakpoint()
|
|
||||||
urls = self.config['urls']
|
urls = self.config['urls']
|
||||||
if not urls:
|
if not urls:
|
||||||
logger.error("No URLs provided. Please provide at least one URL via the command line, or set up an alternative feeder. Use --help for more information.")
|
logger.error("No URLs provided. Please provide at least one URL via the command line, or set up an alternative feeder. Use --help for more information.")
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import sys
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from auto_archiver.__main__ import main
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def orchestration_file(tmp_path):
|
||||||
|
return (tmp_path / "example_orch.yaml").as_posix()
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def autoarchiver(tmp_path, monkeypatch):
|
||||||
|
|
||||||
|
def _autoarchiver(args=["--config", "example_orch.yaml"]):
|
||||||
|
# change dir to tmp_path
|
||||||
|
monkeypatch.chdir(tmp_path)
|
||||||
|
with monkeypatch.context() as m:
|
||||||
|
m.setattr(sys, "argv", ["auto-archiver"] + args)
|
||||||
|
return main()
|
||||||
|
|
||||||
|
return _autoarchiver
|
||||||
|
|
||||||
|
|
||||||
|
def test_run_auto_archiver_no_args(caplog, autoarchiver):
|
||||||
|
with pytest.raises(SystemExit):
|
||||||
|
autoarchiver([])
|
||||||
|
|
||||||
|
assert "provide at least one URL via the command line, or set up an alternative feeder" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
|
def test_run_auto_archiver_invalid_file(caplog, autoarchiver, monkeypatch):
|
||||||
|
# exec 'auto-archiver' on the command lin
|
||||||
|
with pytest.raises(SystemExit):
|
||||||
|
autoarchiver()
|
||||||
|
|
||||||
|
assert "Make sure the file exists and try again, or run without th" in caplog.text
|
Ładowanie…
Reference in New Issue