Includes multilingual etymology fields, seed data for starter names, and CI-ready Python project layout.
35 lines
931 B
Python
35 lines
931 B
Python
"""Shared fixtures for Stork API tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import importlib
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
@pytest.fixture()
|
|
def client(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> TestClient:
|
|
monkeypatch.setenv("STORK_DATA", str(tmp_path / "data"))
|
|
monkeypatch.setenv("STORK_INVITE_TOKEN", "test-invite-token")
|
|
monkeypatch.setenv("STORK_ADMIN_TOKEN", "test-admin-token")
|
|
monkeypatch.setenv("STORK_COOKIE_SECURE", "false")
|
|
|
|
import stork.app as app_mod
|
|
|
|
importlib.reload(app_mod)
|
|
with TestClient(app_mod.app) as test_client:
|
|
yield test_client
|
|
app_mod.store.close()
|
|
|
|
|
|
@pytest.fixture()
|
|
def authed(client: TestClient) -> TestClient:
|
|
res = client.post(
|
|
"/api/session",
|
|
json={"invite": "test-invite-token", "display_name": "Aunt Mira"},
|
|
)
|
|
assert res.status_code == 200
|
|
return client
|