feat: Initialize frontend and backend structure with essential configurations
- 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.
This commit is contained in:
35
backend/tests/test_network_api.py
Normal file
35
backend/tests/test_network_api.py
Normal file
@@ -0,0 +1,35 @@
|
||||
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
|
||||
Reference in New Issue
Block a user