-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtest_db_isolation.py
More file actions
83 lines (65 loc) · 2.7 KB
/
test_db_isolation.py
File metadata and controls
83 lines (65 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import fhirpy_types_r4b as r4b
from fhirpy import AsyncFHIRClient
from tests.conftest import SafeDBFixture
async def test_database_isolation__1(fhir_client: AsyncFHIRClient, safe_db: SafeDBFixture) -> None:
patients = await fhir_client.resources(r4b.Patient).fetch_all()
assert len(patients) == 0
await fhir_client.create(r4b.Patient())
patients = await fhir_client.resources(r4b.Patient).fetch_all()
assert len(patients) == 1
async def test_database_isolation__2(fhir_client: AsyncFHIRClient, safe_db: SafeDBFixture) -> None:
patients = await fhir_client.resources(r4b.Patient).fetch_all()
assert len(patients) == 0
await fhir_client.create(r4b.Patient())
await fhir_client.create(r4b.Patient())
patients = await fhir_client.resources(r4b.Patient).fetch_all()
assert len(patients) == 2 # noqa: PLR2004
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
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