fix: add uvicorn dependency
All checks were successful
PR tests / build-and-smoke (pull_request) Successful in 1m43s

feat: add test_api file
This commit is contained in:
2025-11-25 09:59:24 +01:00
parent c44dc5a61c
commit 811313d1ef
3 changed files with 31 additions and 17 deletions

View File

@@ -46,26 +46,28 @@ jobs:
# show container status to aid debugging
docker ps -a --filter name=semapform-test || true
# perform an in-container GET request (endpoint is a GET) and print attempts/logs
docker exec semapform-test python - << 'PY'
# perform a readiness loop and then run the repo test script to exercise the API
docker exec semapform-test python - << 'PY'
import time, urllib.request, sys
url = 'http://127.0.0.1:8001/api/validate-signature?signature=ST%20250%20U42%20%2815%29'
url = 'http://127.0.0.1:8001/health'
for i in range(20):
try:
with urllib.request.urlopen(url, timeout=3) as r:
print('attempt', i, 'status', r.status)
print(r.read().decode())
if 200 <= r.status < 300:
sys.exit(0)
except Exception as e:
print('attempt', i, 'failed:', e)
time.sleep(1)
print('failed')
try:
with urllib.request.urlopen(url, timeout=2) as r:
print('ready', i, 'status', r.status)
if 200 <= r.status < 300:
sys.exit(0)
except Exception as e:
print('ready attempt', i, 'failed:', e)
time.sleep(1)
print('service did not become ready')
sys.exit(1)
PY
PY
# dump the last 200 lines of logs so this step has visible output
docker logs semapform-test --tail 200 || true
# Run the repository smoke-test script inside the container and surface its output
docker exec semapform-test python test_api.py || true
# dump the last 200 lines of logs so this step always displays useful output
docker logs semapform-test --tail 200 || true
- name: Cleanup container
if: always()

View File

@@ -4,7 +4,11 @@ version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = ["bibapi>=0.0.5", "fastapi>=0.122.0"]
dependencies = [
"bibapi>=0.0.5",
"fastapi>=0.122.0",
"uvicorn>=0.38.0",
]
[[tool.uv.index]]
name = "gitea"
url = "https://git.theprivateserver.de/api/packages/PHB/pypi/simple/"

8
test_api.py Normal file
View File

@@ -0,0 +1,8 @@
# test api endpoint with a signature, print the response
import urllib.request
response = urllib.request.urlopen(
"http://localhost:8001/api/validate-signature?signature=ST%20250%20U42%20%2815%29",
)
print(response.read().decode("utf-8"))