Improve character suggestions and serve pools from the API

This commit is contained in:
2026-09-04 19:58:35 -07:00
parent 1dac2141e6
commit 0ae1701b82
11 changed files with 255 additions and 1255 deletions
+20
View File
@@ -0,0 +1,20 @@
from fastapi.testclient import TestClient
from pirats.main import app
from pirats.validation import sanitize_name, sanitize_text
def test_suggestions_api_covers_rat_records_without_truncation():
# No lifespan needed: these public endpoints do not access the database.
client = TestClient(app)
response = client.get('/api/suggestions')
assert response.status_code == 200
pools = response.json()
assert set(pools) == {'look', 'smell', 'first_words', 'good_at_math', 'like', 'hate'}
for category, entries in pools.items():
assert len(entries) >= 20
assert len({entry.casefold() for entry in entries}) == len(entries)
sanitize = sanitize_name if category == 'smell' else sanitize_text
assert all(entry and sanitize(entry) == entry for entry in entries)
techniques = client.get('/api/suggestions/techniques')
assert techniques.status_code == 200
assert techniques.json()['techniques']