80 lines
2.6 KiB
Python
80 lines
2.6 KiB
Python
def test_health_contains_build_info(tmp_path, monkeypatch):
|
|
monkeypatch.setenv("IMPORTARR_STATE_PATH", str(tmp_path / "state.db"))
|
|
import importarr.main as main
|
|
|
|
payload = main.health()
|
|
assert payload["status"] == "ok"
|
|
assert payload["name"] == "Importarr"
|
|
assert payload["version"]
|
|
|
|
|
|
def test_status_contains_service_configuration(tmp_path, monkeypatch):
|
|
monkeypatch.setenv("IMPORTARR_STATE_PATH", str(tmp_path / "state.db"))
|
|
import importarr.main as main
|
|
|
|
payload = main.status()
|
|
assert payload["build"]["name"] == "Importarr"
|
|
assert "download_root" in payload
|
|
assert "movies_root" in payload
|
|
assert "tv_root" in payload
|
|
assert "auth_enabled" in payload
|
|
|
|
|
|
def test_index_renders_queue_controls(tmp_path, monkeypatch):
|
|
monkeypatch.setenv("IMPORTARR_STATE_PATH", str(tmp_path / "state.db"))
|
|
import importarr.main as main
|
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
response = TestClient(main.app).get("/")
|
|
|
|
assert response.status_code == 200
|
|
assert "Queue controls" in response.text
|
|
assert "cancel-current" in response.text
|
|
|
|
|
|
def test_index_renders_settings_dialog(tmp_path, monkeypatch):
|
|
monkeypatch.setenv("IMPORTARR_STATE_PATH", str(tmp_path / "state.db"))
|
|
import importarr.main as main
|
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
response = TestClient(main.app).get("/")
|
|
|
|
assert response.status_code == 200
|
|
assert "settings-dialog" in response.text
|
|
assert "SABnzbd" in response.text
|
|
assert "Radarr" in response.text
|
|
assert "Sonarr" in response.text
|
|
|
|
|
|
def test_settings_endpoint_persists_arr_connection_values(tmp_path, monkeypatch):
|
|
monkeypatch.setenv("IMPORTARR_STATE_PATH", str(tmp_path / "state.db"))
|
|
import importarr.main as main
|
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
response = TestClient(main.app).post(
|
|
"/api/settings",
|
|
json={
|
|
"sab_url": "http://sab:8080",
|
|
"sab_api_key": "sab-secret",
|
|
"radarr_url": "http://radarr:7878",
|
|
"radarr_api_key": "radarr-secret",
|
|
"sonarr_url": "http://sonarr:8989",
|
|
"sonarr_api_key": "sonarr-secret",
|
|
},
|
|
)
|
|
|
|
assert response.status_code == 200
|
|
assert response.json() == {
|
|
"sab_url": "http://sab:8080",
|
|
"sab_api_key_configured": True,
|
|
"radarr_url": "http://radarr:7878",
|
|
"radarr_api_key_configured": True,
|
|
"sonarr_url": "http://sonarr:8989",
|
|
"sonarr_api_key_configured": True,
|
|
}
|
|
assert main.settings.sab_api_key == "sab-secret"
|
|
assert main.state.get_app_state("radarr_api_key") == "radarr-secret"
|