:chore: Initialisation du projet
This commit is contained in:
1 parent
75a8c6addd
commit
6278d19618
27 files changed
+4418
-81
No files matched your search
@@ -0,0 +1,73 @@
|
||||
import respx
|
||||
from fastapi.testclient import TestClient
|
||||
from httpx import Response
|
||||
|
||||
from app.main import app
|
||||
|
||||
|
||||
def configure_radarr(client: TestClient) -> None:
|
||||
response = client.put(
|
||||
"/api/settings/radarr",
|
||||
json={"url": "http://radarr:7878", "api_key": "test-key"},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_health() -> None:
|
||||
with TestClient(app) as client:
|
||||
response = client.get("/api/health")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["database"] == "ok"
|
||||
|
||||
|
||||
@respx.mock
|
||||
def test_radarr_connection() -> None:
|
||||
respx.get("http://radarr:7878/api/v3/system/status").mock(
|
||||
return_value=Response(200, json={"version": "5.27.0"})
|
||||
)
|
||||
with TestClient(app) as client:
|
||||
configure_radarr(client)
|
||||
response = client.post("/api/settings/radarr/test")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["version"] == "5.27.0"
|
||||
|
||||
|
||||
@respx.mock
|
||||
def test_scan_only_imports_iso_files() -> None:
|
||||
respx.get("http://radarr:7878/api/v3/movie").mock(
|
||||
return_value=Response(
|
||||
200,
|
||||
json=[
|
||||
{
|
||||
"id": 10,
|
||||
"title": "ISO Movie",
|
||||
"year": 2025,
|
||||
"path": "/movies/ISO Movie (2025)",
|
||||
"movieFile": {
|
||||
"id": 20,
|
||||
"relativePath": "ISO Movie (2025).iso",
|
||||
"size": 42_000_000_000,
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"title": "MKV Movie",
|
||||
"year": 2024,
|
||||
"path": "/movies/MKV Movie (2024)",
|
||||
"movieFile": {
|
||||
"id": 21,
|
||||
"relativePath": "MKV Movie (2024).mkv",
|
||||
"size": 10_000_000_000,
|
||||
},
|
||||
},
|
||||
],
|
||||
)
|
||||
)
|
||||
with TestClient(app) as client:
|
||||
configure_radarr(client)
|
||||
scan = client.post("/api/scans")
|
||||
movies = client.get("/api/movies")
|
||||
assert scan.status_code == 200
|
||||
assert scan.json()["iso_files"] == 1
|
||||
assert [movie["title"] for movie in movies.json()] == ["ISO Movie"]
|
||||
|
||||
Reference in new issue
Block a user