Part of #2400. Follow-up to #2368. Requires the shared httpx prerequisite (see the meta issue).
What
Cover the inventory-facts HTTP endpoints, which read straight from Redis:
GET /v1/inventory/hosts/{host}/facts (osism/api.py:927)
GET /v1/inventory/hosts/{host}/facts/{fact} (osism/api.py:966)
Both call utils.redis.get("ansible_facts{host}"). Driving them through fastapi.testclient.TestClient against the live Redis exercises the API↔Redis path end-to-end.
Scope
- Seed
ansible_facts<host> in Redis → GET .../facts returns 200 with the parsed facts and correct count.
- Single fact:
GET .../facts/{fact} returns the value; unknown fact → 404.
- Unknown host (no key) → 404.
- Malformed JSON in Redis → 500.
Notes / Where
New file tests/integration/test_api_facts.py. Importing osism.api wires the event bridge to Redis at import time — fine in the integration env where Redis is up (and the suite is skipped without it). Add httpx to [dev-packages] in Pipfile (TestClient needs it). Clean up seeded keys per test.
Part of #2400. Follow-up to #2368. Requires the shared
httpxprerequisite (see the meta issue).What
Cover the inventory-facts HTTP endpoints, which read straight from Redis:
GET /v1/inventory/hosts/{host}/facts(osism/api.py:927)GET /v1/inventory/hosts/{host}/facts/{fact}(osism/api.py:966)Both call
utils.redis.get("ansible_facts{host}"). Driving them throughfastapi.testclient.TestClientagainst the live Redis exercises the API↔Redis path end-to-end.Scope
ansible_facts<host>in Redis →GET .../factsreturns 200 with the parsed facts and correct count.GET .../facts/{fact}returns the value; unknown fact → 404.Notes / Where
New file
tests/integration/test_api_facts.py. Importingosism.apiwires the event bridge to Redis at import time — fine in the integration env where Redis is up (and the suite is skipped without it). Addhttpxto[dev-packages]inPipfile(TestClient needs it). Clean up seeded keys per test.