Initial commit

This commit is contained in:
hiperman
2025-12-04 00:33:37 -05:00
commit 7ca0a21283
798 changed files with 190424 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
import pytest
from httpx import AsyncClient
from pathlib import Path
async def test_get_libraries_without_auth(client: AsyncClient) -> None:
response = await client.get("/libraries?library_id=1")
assert response.status_code == 401
async def test_get_libraries_with_auth(authenticated_client: AsyncClient) -> None:
response = await authenticated_client.get("/libraries?library_id=1")
assert response.status_code == 200
@pytest.mark.parametrize(
("name", "read_only", "expected_status_code"),
[("Test Library", False, 201), ("Read-Only Library", True, 400)],
)
async def test_create_library(
authenticated_client: AsyncClient,
tmp_path: Path,
name: str,
read_only: bool,
expected_status_code: int,
) -> None:
library_data = {
"name": "Test Library",
"root_path": f"{tmp_path}/books",
"path_template": "{author}/{title}",
"read_only": read_only,
}
response = await authenticated_client.post("/libraries", json=library_data)
assert response.status_code == expected_status_code
if response.status_code == 201:
result = response.json()
assert result["name"] == "Test Library"
assert result["root_path"] == f"{tmp_path}/books"
assert result["path_template"] == "{author}/{title}"
assert result["read_only"] == False
assert result["description"] is None