- Added TypeScript build info for frontend. - Created Vite configuration for React application. - Implemented pre-commit hook to run checks before commits. - Set up PostgreSQL Dockerfile with PostGIS support and initialization scripts. - Added database creation script for PostgreSQL with necessary extensions. - Established Python project configuration with dependencies and development tools. - Developed pre-commit script to enforce code quality checks for backend and frontend. - Created PowerShell script to set up Git hooks path.
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
from fastapi.testclient import TestClient
|
|
|
|
from backend.app.main import app
|
|
|
|
AUTH_CREDENTIALS = {"username": "demo", "password": "railgame123"}
|
|
|
|
client = TestClient(app)
|
|
|
|
|
|
def _authenticate() -> str:
|
|
response = client.post("/api/auth/login", json=AUTH_CREDENTIALS)
|
|
assert response.status_code == 200
|
|
return response.json()["accessToken"]
|
|
|
|
|
|
def test_network_snapshot_requires_authentication() -> None:
|
|
response = client.get("/api/network")
|
|
assert response.status_code == 401
|
|
|
|
|
|
def test_network_snapshot_endpoint_returns_collections() -> None:
|
|
token = _authenticate()
|
|
response = client.get(
|
|
"/api/network", headers={"Authorization": f"Bearer {token}"}
|
|
)
|
|
assert response.status_code == 200
|
|
|
|
payload = response.json()
|
|
assert set(payload.keys()) == {"stations", "tracks", "trains"}
|
|
assert all(isinstance(payload[key], list) for key in payload)
|
|
assert payload["stations"], "Expected sample station data"
|
|
assert payload["trains"], "Expected sample train data"
|
|
|
|
station = payload["stations"][0]
|
|
assert "name" in station and "createdAt" in station
|