aidbox-python-sdk 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aidbox_python_sdk-0.2.0/aidbox_python_sdk.egg-info → aidbox_python_sdk-0.2.1}/PKG-INFO +3 -10
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/README.md +2 -9
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk/__init__.py +1 -1
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk/handlers.py +12 -5
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1/aidbox_python_sdk.egg-info}/PKG-INFO +3 -10
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/tests/test_sdk.py +20 -1
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/LICENSE.md +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/MANIFEST.in +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk/aidboxpy.py +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk/app_keys.py +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk/db.py +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk/db_migrations.py +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk/exceptions.py +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk/main.py +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk/py.typed +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk/pytest_plugin.py +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk/sdk.py +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk/settings.py +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk/types.py +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk.egg-info/SOURCES.txt +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk.egg-info/dependency_links.txt +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk.egg-info/not-zip-safe +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk.egg-info/requires.txt +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk.egg-info/top_level.txt +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/pyproject.toml +0 -0
- {aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aidbox-python-sdk
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Aidbox SDK for python
|
|
5
5
|
Author-email: "beda.software" <aidbox-python-sdk@beda.software>
|
|
6
6
|
License: MIT License
|
|
@@ -251,13 +251,6 @@ In your project’s **`conftest.py`** (e.g. `tests/conftest.py`), register the p
|
|
|
251
251
|
pytest_plugins = ["aidbox_python_sdk.pytest_plugin"]
|
|
252
252
|
```
|
|
253
253
|
|
|
254
|
-
Alternatively you can configure it in **`pyproject.toml`**:
|
|
255
|
-
|
|
256
|
-
```toml
|
|
257
|
-
[tool.pytest.ini_options]
|
|
258
|
-
pytest_plugins = ["aidbox_python_sdk.pytest_plugin"]
|
|
259
|
-
```
|
|
260
|
-
|
|
261
254
|
### Configuring the app factory
|
|
262
255
|
|
|
263
256
|
The plugin needs your app factory (the callable that returns the `web.Application`). You can set it in pytest ini:
|
|
@@ -265,7 +258,6 @@ The plugin needs your app factory (the callable that returns the `web.Applicatio
|
|
|
265
258
|
**`pyproject.toml`**
|
|
266
259
|
```toml
|
|
267
260
|
[tool.pytest.ini_options]
|
|
268
|
-
pytest_plugins = ["aidbox_python_sdk.pytest_plugin"]
|
|
269
261
|
aidbox_create_app = "main:create_app"
|
|
270
262
|
```
|
|
271
263
|
|
|
@@ -317,8 +309,9 @@ Example:
|
|
|
317
309
|
```python
|
|
318
310
|
@pytest.mark.asyncio
|
|
319
311
|
async def test_patient_subscription(aidbox_client, safe_db, sdk):
|
|
312
|
+
was_patient_sub_triggered = sdk.was_subscription_triggered("Patient")
|
|
320
313
|
patient = await aidbox_client.resource("Patient", name=[{"family": "Test"}]).save()
|
|
321
|
-
await
|
|
314
|
+
await was_patient_sub_triggered
|
|
322
315
|
# assertions...
|
|
323
316
|
```
|
|
324
317
|
|
|
@@ -189,13 +189,6 @@ In your project’s **`conftest.py`** (e.g. `tests/conftest.py`), register the p
|
|
|
189
189
|
pytest_plugins = ["aidbox_python_sdk.pytest_plugin"]
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
Alternatively you can configure it in **`pyproject.toml`**:
|
|
193
|
-
|
|
194
|
-
```toml
|
|
195
|
-
[tool.pytest.ini_options]
|
|
196
|
-
pytest_plugins = ["aidbox_python_sdk.pytest_plugin"]
|
|
197
|
-
```
|
|
198
|
-
|
|
199
192
|
### Configuring the app factory
|
|
200
193
|
|
|
201
194
|
The plugin needs your app factory (the callable that returns the `web.Application`). You can set it in pytest ini:
|
|
@@ -203,7 +196,6 @@ The plugin needs your app factory (the callable that returns the `web.Applicatio
|
|
|
203
196
|
**`pyproject.toml`**
|
|
204
197
|
```toml
|
|
205
198
|
[tool.pytest.ini_options]
|
|
206
|
-
pytest_plugins = ["aidbox_python_sdk.pytest_plugin"]
|
|
207
199
|
aidbox_create_app = "main:create_app"
|
|
208
200
|
```
|
|
209
201
|
|
|
@@ -255,8 +247,9 @@ Example:
|
|
|
255
247
|
```python
|
|
256
248
|
@pytest.mark.asyncio
|
|
257
249
|
async def test_patient_subscription(aidbox_client, safe_db, sdk):
|
|
250
|
+
was_patient_sub_triggered = sdk.was_subscription_triggered("Patient")
|
|
258
251
|
patient = await aidbox_client.resource("Patient", name=[{"family": "Test"}]).save()
|
|
259
|
-
await
|
|
252
|
+
await was_patient_sub_triggered
|
|
260
253
|
# assertions...
|
|
261
254
|
```
|
|
262
255
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
import json
|
|
2
3
|
import logging
|
|
3
4
|
from typing import Any
|
|
4
5
|
|
|
5
6
|
from aiohttp import web
|
|
6
|
-
from fhirpy.base.exceptions import OperationOutcome
|
|
7
|
+
from fhirpy.base.exceptions import BaseFHIRError, OperationOutcome
|
|
7
8
|
|
|
8
9
|
from . import app_keys as ak
|
|
9
10
|
|
|
@@ -48,6 +49,12 @@ async def operation(request: web.Request, data: dict[str, Any]):
|
|
|
48
49
|
return result
|
|
49
50
|
except OperationOutcome as exc:
|
|
50
51
|
return web.json_response(exc.resource, status=422)
|
|
52
|
+
except BaseFHIRError as exc:
|
|
53
|
+
try:
|
|
54
|
+
payload = json.loads(str(exc))
|
|
55
|
+
return web.json_response(payload, status=422)
|
|
56
|
+
except (json.JSONDecodeError, TypeError):
|
|
57
|
+
return web.Response(text=str(exc), status=422, content_type="text/plain")
|
|
51
58
|
|
|
52
59
|
|
|
53
60
|
TYPES = {
|
|
@@ -59,10 +66,10 @@ TYPES = {
|
|
|
59
66
|
@routes.post("/aidbox")
|
|
60
67
|
async def dispatch(request):
|
|
61
68
|
logger.debug("Dispatch new request %s %s", request.method, request.url)
|
|
62
|
-
|
|
63
|
-
if "type" in
|
|
64
|
-
logger.debug("Dispatch to `%s` handler",
|
|
65
|
-
return await TYPES[
|
|
69
|
+
data = await request.json()
|
|
70
|
+
if "type" in data and data["type"] in TYPES:
|
|
71
|
+
logger.debug("Dispatch to `%s` handler", data["type"])
|
|
72
|
+
return await TYPES[data["type"]](request, data)
|
|
66
73
|
req = {
|
|
67
74
|
"method": request.method,
|
|
68
75
|
"url": str(request.url),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aidbox-python-sdk
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Aidbox SDK for python
|
|
5
5
|
Author-email: "beda.software" <aidbox-python-sdk@beda.software>
|
|
6
6
|
License: MIT License
|
|
@@ -251,13 +251,6 @@ In your project’s **`conftest.py`** (e.g. `tests/conftest.py`), register the p
|
|
|
251
251
|
pytest_plugins = ["aidbox_python_sdk.pytest_plugin"]
|
|
252
252
|
```
|
|
253
253
|
|
|
254
|
-
Alternatively you can configure it in **`pyproject.toml`**:
|
|
255
|
-
|
|
256
|
-
```toml
|
|
257
|
-
[tool.pytest.ini_options]
|
|
258
|
-
pytest_plugins = ["aidbox_python_sdk.pytest_plugin"]
|
|
259
|
-
```
|
|
260
|
-
|
|
261
254
|
### Configuring the app factory
|
|
262
255
|
|
|
263
256
|
The plugin needs your app factory (the callable that returns the `web.Application`). You can set it in pytest ini:
|
|
@@ -265,7 +258,6 @@ The plugin needs your app factory (the callable that returns the `web.Applicatio
|
|
|
265
258
|
**`pyproject.toml`**
|
|
266
259
|
```toml
|
|
267
260
|
[tool.pytest.ini_options]
|
|
268
|
-
pytest_plugins = ["aidbox_python_sdk.pytest_plugin"]
|
|
269
261
|
aidbox_create_app = "main:create_app"
|
|
270
262
|
```
|
|
271
263
|
|
|
@@ -317,8 +309,9 @@ Example:
|
|
|
317
309
|
```python
|
|
318
310
|
@pytest.mark.asyncio
|
|
319
311
|
async def test_patient_subscription(aidbox_client, safe_db, sdk):
|
|
312
|
+
was_patient_sub_triggered = sdk.was_subscription_triggered("Patient")
|
|
320
313
|
patient = await aidbox_client.resource("Patient", name=[{"family": "Test"}]).save()
|
|
321
|
-
await
|
|
314
|
+
await was_patient_sub_triggered
|
|
322
315
|
# assertions...
|
|
323
316
|
```
|
|
324
317
|
|
|
@@ -4,6 +4,7 @@ from unittest import mock
|
|
|
4
4
|
|
|
5
5
|
import pytest
|
|
6
6
|
from fhirpathpy import evaluate
|
|
7
|
+
from fhirpy.base.exceptions import OperationOutcome
|
|
7
8
|
|
|
8
9
|
import main
|
|
9
10
|
from aidbox_python_sdk.db import DBProxy
|
|
@@ -182,10 +183,28 @@ async def test_aidbox_db_fixture(client, aidbox_db: DBProxy, safe_db):
|
|
|
182
183
|
"""
|
|
183
184
|
Test that aidbox_db fixture works with isolated DB Proxy from app's instance
|
|
184
185
|
"""
|
|
185
|
-
response = await client.get("/
|
|
186
|
+
response = await client.get("/db-tests")
|
|
186
187
|
assert response.status == 200
|
|
187
188
|
json = await response.json()
|
|
188
189
|
assert json == [{"id": "app-test"}]
|
|
189
190
|
|
|
190
191
|
app_ids = await main.get_app_ids(aidbox_db)
|
|
191
192
|
assert app_ids == [{"id": "app-test"}]
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
async def test_operation_base_fhir_error_json_test_op(aidbox_client):
|
|
196
|
+
with pytest.raises(OperationOutcome) as exc:
|
|
197
|
+
await aidbox_client.execute("/$base-fhir-error-json-test")
|
|
198
|
+
assert exc.value.resource.get("issue")[0].get("diagnostics") == "Resource Patient/id not found"
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
async def test_operation_base_fhir_error_text_test_op(aidbox_client):
|
|
202
|
+
with pytest.raises(OperationOutcome) as exc:
|
|
203
|
+
await aidbox_client.execute("/$base-fhir-error-text-test")
|
|
204
|
+
assert exc.value.resource.get("issue")[0].get("diagnostics") == "plain"
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
async def test_operation_outcome_test_op(aidbox_client):
|
|
208
|
+
with pytest.raises(OperationOutcome) as exc:
|
|
209
|
+
await aidbox_client.execute("/$operation-outcome-test")
|
|
210
|
+
assert exc.value.resource.get("issue")[0].get("diagnostics") == "test reason"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aidbox_python_sdk-0.2.0 → aidbox_python_sdk-0.2.1}/aidbox_python_sdk.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|