apitest: query tracks

This commit is contained in:
Helmut Merz 2026-09-18 10:44:10 +02:00
parent 635b18bd08
commit b3d6512987
2 changed files with 19 additions and 0 deletions

View file

@ -1,5 +1,9 @@
# scopes.api.main
import config
from scopes.storage import tracking
import transaction
from fastapi import FastAPI
app = FastAPI()
@ -12,3 +16,11 @@ async def read_root():
async def read_person(name: str, q: str | None = None):
return {'name': name, 'query': q}
@app.get('/tracks')
async def get_tracks():
storage = config.storageFactory(config.dbschema)
tracks = storage.create(tracking.Container)
result = [tr.asDict() for tr in tracks.query()]
transaction.commit()
return result

View file

@ -47,4 +47,11 @@ def test_root():
response = clt.get('/')
assert response.status_code == 200
assert response.json() == {'Hello': 'World'}
tracks = clt.get('/tracks').json()
assert len(tracks) == 1
tr = tracks[0]
tr['timeStamp'] = '...'
assert tr == {'uid': 'rec-1', 'head': {'taskId': 't01', 'userName': 'john'},
'data': {'activity': 'testing'}, 'timeStamp': '...'}
assert tr['uid'] == 'rec-1'