7d40cf95bf
- FastAPI Identify API (port 8081) - Neo4j propertygraf (64 noder, 80 kanter) - Ingest-pipeline (Python) - Byggscript + integrationstester - Docker Compose setup
79 lines
2.1 KiB
Python
79 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Integrationstester för Landvex Identify API.
|
|
"""
|
|
import requests
|
|
import sys
|
|
|
|
BASE = "http://localhost:8081"
|
|
|
|
def test_health():
|
|
r = requests.get(f"{BASE}/health")
|
|
assert r.status_code == 200
|
|
d = r.json()
|
|
assert d["status"] == "ok"
|
|
assert d["poster"] > 0
|
|
print(f"✅ Health: {d['poster']} poster, {d['kanter']} kanter")
|
|
|
|
def test_search():
|
|
r = requests.get(f"{BASE}/v0/search", params={"q": "belysning"})
|
|
assert r.status_code == 200
|
|
d = r.json()
|
|
assert d["antal"] > 0
|
|
print(f"✅ Search: {d['antal']} träffar för 'belysning'")
|
|
|
|
def test_get_object():
|
|
r = requests.get(f"{BASE}/v0/objects/LVX-TRP-0102")
|
|
assert r.status_code == 200
|
|
d = r.json()
|
|
assert d["lvx_id"] == "LVX-TRP-0102"
|
|
assert d["posttyp"] == "objektklass"
|
|
assert "kallor" in d
|
|
print(f"✅ Object: {d['namn']['sv']} ({len(d['kallor'])} källor)")
|
|
|
|
def test_succession():
|
|
r = requests.get(f"{BASE}/v0/objects/LVX-TRP-0102/succession")
|
|
assert r.status_code == 200
|
|
print("✅ Succession: OK")
|
|
|
|
def test_standard():
|
|
r = requests.get(f"{BASE}/v0/standards/EN%2012439-5/objects")
|
|
assert r.status_code == 200
|
|
d = r.json()
|
|
print(f"✅ Standard: {d['antal']} objekt kopplade till EN 12439-5")
|
|
|
|
def test_feedback():
|
|
r = requests.post(f"{BASE}/v0/feedback", json={
|
|
"kommentar": "Testbounty från integrationstest"
|
|
})
|
|
assert r.status_code == 200
|
|
d = r.json()
|
|
assert d["status"] == "skapad"
|
|
print(f"✅ Feedback: bounty {d['bounty_id']} skapad")
|
|
|
|
def test_404():
|
|
r = requests.get(f"{BASE}/v0/objects/LVX-XXX-9999")
|
|
assert r.status_code == 404
|
|
print("✅ 404: OK")
|
|
|
|
def main():
|
|
print("Landvex API Integrationstester")
|
|
print("=" * 40)
|
|
try:
|
|
test_health()
|
|
test_search()
|
|
test_get_object()
|
|
test_succession()
|
|
test_standard()
|
|
test_feedback()
|
|
test_404()
|
|
print("=" * 40)
|
|
print("✅ Alla tester passerade!")
|
|
return 0
|
|
except Exception as e:
|
|
print(f"❌ FAIL: {e}")
|
|
return 1
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|