Testing#
Running Tests#
pip install -e ".[test]"
pytest -v
Tests run automatically via GitHub Actions on every push and pull request
to main (Python 3.10–3.13). See .github/workflows/tests.yml.
Test Strategy#
The test suite focuses on logic that can break in non-obvious ways:
resolution order, parsing, formatting, and protocol handling. Service
classes (chat, voice, arcana) are thin HTTP wrappers — their correctness
is best verified by integration tests against the real API, not by mocking
requests.
Tests are deliberately kept minimal. Each test either:
protects a priority ordering that could silently regress,
validates parsing of a real-world format variant, or
has already caught a bug during development.
Test Inventory#
test_auth.py — API Key Discovery#
Test |
Purpose |
|---|---|
|
|
|
|
|
|
|
Whitespace around env var value is stripped |
|
Empty |
|
|
|
Lines starting with |
|
|
|
Single and double quotes stripped from values |
|
|
|
Env var takes priority over |
|
|
test_auth.py — ARCANA ID Priority Chain#
Test |
Purpose |
|---|---|
|
|
|
|
|
First |
|
First |
|
|
test_auth.py — ARCANA ID Source Merging#
Test |
Purpose |
|---|---|
|
|
|
|
|
|
|
No configuration returns |
|
All sources (env, toml ids, toml labels, numbered) merge into one dict |
test_auth.py — Legacy Removal#
Test |
Purpose |
|---|---|
|
|
test_auth.py — Owner Prefix Resolution#
Test |
Purpose |
|---|---|
|
Username configured, ID has no |
|
No username, ID already has |
|
Username set and ID has |
|
No username and no |
test_auth.py — extract_arcana_name#
Test |
Purpose |
|---|---|
|
|
|
Only the first |
|
Spaces in arcana names are preserved |
test_auth.py — Username and Summary#
Test |
Purpose |
|---|---|
|
Username loaded from |
|
Env var |
|
Returns |
|
|
test_rate_limits.py — Header Parsing and Formatting#
Test |
Purpose |
|---|---|
|
All 9 rate-limit headers map to correct dataclass fields |
|
Non-numeric header values are silently skipped |
|
|
|
|
test_streaming.py — SSE Line Parsing#
Test |
Purpose |
|---|---|
|
Standard |
|
Generator stops at |
|
Invalid JSON lines are silently skipped |
|
|
|
HTTP errors raise before iteration begins |
test_exceptions.py — Error Handling#
Test |
Purpose |
|---|---|
|
|