Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aidbox_python_sdk/db_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
FOR e IN (
SELECT table_name
FROM information_schema.columns
WHERE column_name = 'txid' AND table_schema = 'public' AND table_name NOT LIKE '%_history'
WHERE column_name = 'txid' AND table_schema = 'public' AND table_name NOT LIKE '%\\_history' ESCAPE '\\'
) LOOP
EXECUTE 'DELETE FROM "' || e.table_name || '" WHERE txid > ' || $1 ;
END LOOP;
Expand Down
4 changes: 2 additions & 2 deletions run_test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

if [ -f "envs/aidbox" ]; then
export `cat envs/aidbox`
if [ -f ".env" ]; then
export `cat .env`
fi

if [ -z "${AIDBOX_LICENSE}" ]; then
Expand Down
60 changes: 60 additions & 0 deletions tests/test_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,63 @@ async def test_database_isolation__2(aidbox_client, safe_db):

patients = await aidbox_client.resources("Patient").fetch_all()
assert len(patients) == 4


@pytest.mark.asyncio()
async def test_database_isolation_with_history_in_name__1(aidbox_client, safe_db):
resources = await aidbox_client.resources("FamilyMemberHistory").fetch_all()
assert len(resources) == 0

resource = aidbox_client.resource(
"FamilyMemberHistory",
status="completed",
patient={
"identifier": {"system": "http://example.org/test-patients", "value": "test-patient-1"}
},
relationship={
"coding": [
{"system": "http://terminology.hl7.org/CodeSystem/v3-RoleCode", "code": "FTH"}
]
},
)
await resource.save()

resources = await aidbox_client.resources("FamilyMemberHistory").fetch_all()
assert len(resources) == 1


@pytest.mark.asyncio()
async def test_database_isolation_with_history_in_name__2(aidbox_client, safe_db):
resources = await aidbox_client.resources("FamilyMemberHistory").fetch_all()
assert len(resources) == 0

resource1 = aidbox_client.resource(
"FamilyMemberHistory",
status="completed",
patient={
"identifier": {"system": "http://example.org/test-patients", "value": "test-patient-1"}
},
relationship={
"coding": [
{"system": "http://terminology.hl7.org/CodeSystem/v3-RoleCode", "code": "FTH"}
]
},
)
await resource1.save()

resource2 = aidbox_client.resource(
"FamilyMemberHistory",
status="completed",
patient={
"identifier": {"system": "http://example.org/test-patients", "value": "test-patient-2"}
},
relationship={
"coding": [
{"system": "http://terminology.hl7.org/CodeSystem/v3-RoleCode", "code": "MTH"}
]
},
)
await resource2.save()

resources = await aidbox_client.resources("FamilyMemberHistory").fetch_all()
assert len(resources) == 2