21 lines
954 B
Python
21 lines
954 B
Python
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']
|