fix: add uvicorn dependency
All checks were successful
PR tests / build-and-smoke (pull_request) Successful in 1m43s
All checks were successful
PR tests / build-and-smoke (pull_request) Successful in 1m43s
feat: add test_api file
This commit is contained in:
@@ -46,25 +46,27 @@ 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
|
||||
# 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())
|
||||
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('attempt', i, 'failed:', e)
|
||||
print('ready attempt', i, 'failed:', e)
|
||||
time.sleep(1)
|
||||
print('failed')
|
||||
print('service did not become ready')
|
||||
sys.exit(1)
|
||||
PY
|
||||
|
||||
# dump the last 200 lines of logs so this step has visible output
|
||||
# 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
|
||||
|
||||
@@ -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
8
test_api.py
Normal 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"))
|
||||
Reference in New Issue
Block a user