Skip to content

Commit 7467221

Browse files
committed
Add tests for compliance attribute for operations
Ref: Aidbox#69
1 parent 91b7248 commit 7467221

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

run_test.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

3+
if [ -f "env_tests" ]; then
4+
export `cat env_tests`
5+
fi
6+
7+
if [ -z "${AIDBOX_LICENSE}" ]; then
8+
echo "AIDBOX_LICENSE is required to run tests"
9+
exit 1
10+
fi
11+
12+
13+
docker compose -f docker-compose.yaml pull --quiet
314
docker compose -f docker-compose.yaml up --exit-code-from app app
15+
16+
exit $?

tests/test_sdk.py

+30
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,36 @@
77
import main
88

99

10+
@pytest.mark.asyncio
11+
async def test_operation_with_compliance_params(client):
12+
sdk = client.server.app["sdk"]
13+
14+
compliance = {
15+
"fhirCode": "observation-custom-op",
16+
"fhirUrl": "http://test.com",
17+
"fhirResource": ["Observation"],
18+
}
19+
20+
@sdk.operation(["POST"], ["Observation", "observation-custom-op"], compliance=compliance)
21+
async def observation_custom_op(operation, request):
22+
return {"message": "Observation custom operation response"}
23+
24+
25+
operation_id = "POST.tests.test_sdk.observation_custom_op.Observation_observation-custom-op"
26+
27+
assert operation_id in sdk._operations
28+
29+
assert sdk._operations[operation_id]["fhirCode"] == "observation-custom-op"
30+
assert sdk._operations[operation_id]["fhirUrl"] == "http://test.com"
31+
assert sdk._operations[operation_id]["fhirResource"] == ["Observation"]
32+
33+
handler = sdk.get_operation_handler(operation_id)
34+
assert handler is not None
35+
36+
response = await handler({}, {})
37+
assert response == {"message": "Observation custom operation response"}
38+
39+
1040
@pytest.mark.asyncio()
1141
async def test_health_check(client):
1242
resp = await client.get("/health")

0 commit comments

Comments
 (0)