✨ Endpoints qBittorrent (GET/PUT/test) persistant dans conf.json
This commit is contained in:
1 parent
de4a9b212f
commit
cfc0c54181
2 files changed
+86
No files matched your search
@@ -1,7 +1,10 @@
|
||||
import json
|
||||
|
||||
import respx
|
||||
from fastapi.testclient import TestClient
|
||||
from httpx import Response
|
||||
|
||||
from app.conf_store import config_path
|
||||
from app.main import app
|
||||
|
||||
|
||||
@@ -70,3 +73,38 @@ def test_scan_only_imports_iso_files() -> None:
|
||||
assert scan.status_code == 200
|
||||
assert scan.json()["iso_files"] == 1
|
||||
assert [movie["title"] for movie in movies.json()] == ["ISO Movie"]
|
||||
|
||||
|
||||
@respx.mock
|
||||
def test_qbittorrent_connection() -> None:
|
||||
respx.post("http://qbit:8080/api/v2/auth/login").mock(
|
||||
return_value=Response(200, text="Ok.")
|
||||
)
|
||||
respx.get("http://qbit:8080/api/v2/app/version").mock(
|
||||
return_value=Response(200, text="v5.0.2")
|
||||
)
|
||||
with TestClient(app) as client:
|
||||
response = client.put(
|
||||
"/api/settings/qbittorrent",
|
||||
json={"url": "http://qbit:8080", "username": "admin", "password": "pass"},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
test = client.post("/api/settings/qbittorrent/test")
|
||||
assert test.status_code == 200
|
||||
assert test.json()["version"] == "v5.0.2"
|
||||
|
||||
|
||||
def test_settings_persist_to_conf_json() -> None:
|
||||
with TestClient(app) as client:
|
||||
put = client.put(
|
||||
"/api/settings/qbittorrent",
|
||||
json={"url": "http://qbit:8080/", "username": "admin", "password": "pass"},
|
||||
)
|
||||
got = client.get("/api/settings/qbittorrent")
|
||||
assert put.status_code == 200
|
||||
assert put.json()["password_configured"] is True
|
||||
assert got.json()["url"] == "http://qbit:8080"
|
||||
raw = json.loads(config_path().read_text(encoding="utf-8"))
|
||||
assert raw["qbittorrent"]["url"] == "http://qbit:8080"
|
||||
assert raw["qbittorrent"]["username"] == "admin"
|
||||
assert raw["qbittorrent"]["password"] == "pass"
|
||||
Reference in new issue
Block a user