Target manual importer from UI controls #31
This commit is contained in:
@@ -42,6 +42,57 @@ def test_start_reenables_manual_queue_sync(tmp_path, monkeypatch):
|
||||
assert len(main.state.list_queue_items()) == 1
|
||||
|
||||
|
||||
def test_default_control_commands_target_manual_import_service(monkeypatch):
|
||||
monkeypatch.delenv("IMPORTARR_START_COMMAND", raising=False)
|
||||
monkeypatch.delenv("IMPORTARR_STOP_COMMAND", raising=False)
|
||||
monkeypatch.delenv("IMPORTARR_RESTART_COMMAND", raising=False)
|
||||
|
||||
settings = Settings.from_env()
|
||||
|
||||
assert settings.start_command == ["systemctl", "start", "manual-media-import.service"]
|
||||
assert settings.stop_command == ["systemctl", "stop", "manual-media-import.service"]
|
||||
assert settings.restart_command == ["systemctl", "restart", "manual-media-import.service"]
|
||||
|
||||
|
||||
def test_start_control_starts_manual_import_service(tmp_path, monkeypatch):
|
||||
main, _download, _movies, _tv = configure_main(tmp_path, monkeypatch)
|
||||
main.settings.start_command = ["systemctl", "start", "manual-media-import.service"]
|
||||
|
||||
calls = []
|
||||
|
||||
def fake_run(command, **kwargs):
|
||||
calls.append(command)
|
||||
return main.subprocess.CompletedProcess(command, 0, stdout="started", stderr="")
|
||||
|
||||
monkeypatch.setattr(main.subprocess, "run", fake_run)
|
||||
|
||||
result = main.start_queue()
|
||||
|
||||
assert result["control"]["queue_mode"] == "running"
|
||||
assert result["command_result"]["command"] == ["systemctl", "start", "manual-media-import.service"]
|
||||
assert calls == [["systemctl", "start", "manual-media-import.service"]]
|
||||
|
||||
|
||||
def test_stop_control_stops_manual_import_service(tmp_path, monkeypatch):
|
||||
main, _download, _movies, _tv = configure_main(tmp_path, monkeypatch)
|
||||
main.settings.stop_command = ["systemctl", "stop", "manual-media-import.service"]
|
||||
|
||||
calls = []
|
||||
|
||||
def fake_run(command, **kwargs):
|
||||
calls.append(command)
|
||||
return main.subprocess.CompletedProcess(command, 0, stdout="stopped", stderr="")
|
||||
|
||||
monkeypatch.setattr(main.subprocess, "run", fake_run)
|
||||
|
||||
result = main.stop_queue()
|
||||
|
||||
assert result["control"]["queue_mode"] == "stopped"
|
||||
assert result["control"]["cancel_requested"] is True
|
||||
assert result["command_result"]["command"] == ["systemctl", "stop", "manual-media-import.service"]
|
||||
assert calls == [["systemctl", "stop", "manual-media-import.service"]]
|
||||
|
||||
|
||||
def test_queue_jobs_include_groups_and_manual_context(tmp_path, monkeypatch):
|
||||
main, download, _movies, _tv = configure_main(tmp_path, monkeypatch)
|
||||
batch = download / "Release" / "Season 1"
|
||||
|
||||
Reference in New Issue
Block a user