Files
finance/backend/tests/test_api.py
T
k1nq d582f15681 feat: add tests for import polling, login page, money utilities, and query keys
- Implemented tests for import polling functionality, ensuring correct behavior for active and terminal import statuses.
- Created tests for the login page, validating user interactions and error handling.
- Added unit tests for money utility functions, covering parsing, formatting, and summation of monetary values.
- Developed tests for query keys, ensuring proper scoping and invalidation roots.

chore: setup testing environment and configuration

- Added setup file for testing with Vitest and Testing Library.
- Configured TypeScript and Vite for the frontend project.
- Created Docker and Nginx configurations for local development and production environments.
- Established a PostgreSQL initialization script for setting up application roles.

docs: add README and environment configuration for infra

- Included README for the infra directory, detailing local development setup and service descriptions.
- Created an example environment configuration file for local development with placeholders for sensitive information.
2026-09-14 09:26:33 +05:00

46 lines
1.5 KiB
Python

from fastapi.testclient import TestClient
def test_invite_login_and_authenticated_space(client: TestClient) -> None:
invite = client.post(
"/api/v1/admin/invitations",
headers={"X-Admin-Token": "test-admin-token"},
json={"email": "Person@Example.com"},
)
assert invite.status_code == 201, invite.text
accepted = client.post(
"/api/v1/auth/invitations/accept",
json={
"token": invite.json()["token"],
"password": "a-long-password-for-tests",
"fullName": "Test Person",
"locale": "en",
},
)
assert accepted.status_code == 201, accepted.text
assert accepted.json()["email"] == "person@example.com"
assert client.get("/api/v1/spaces/current").status_code == 200
csrf = client.cookies["csrf_token"]
account = client.post(
"/api/v1/accounts",
headers={"X-CSRF-Token": csrf},
json={
"name": "Wallet",
"type": "cash",
"openedOn": "2026-09-01",
"openingBalanceKopecks": 12_500,
},
)
assert account.status_code == 201, account.text
assert account.json()["balanceKopecks"] == 12_500
def test_openapi_contains_critical_paths(client: TestClient) -> None:
schema = client.get("/api/v1/openapi.json").json()
paths = schema["paths"]
assert "/api/v1/operations" in paths
assert "/api/v1/imports/{document_id}/confirm" in paths
assert "/api/v1/budget/close" in paths
assert "/api/v1/analytics/balances" in paths