Skip to content

Commit 9bf6440

Browse files
committed
Add note about subscriptions without safe_db
1 parent e4ada54 commit 9bf6440

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,25 @@ def create_app():
233233

234234
Use the **`safe_db`** fixture in tests that create or change data. It records the current transaction id, runs your test, then rolls back everything created in that test so the DB stays clean.
235235

236+
**NOTE:** Without `safe_db`, all subscriptions are implicitly ignored for that test.
237+
238+
Example:
239+
240+
```python
241+
@pytest.mark.asyncio
242+
async def test_create_patient(aidbox_client, safe_db):
243+
patient = await aidbox_client.resource("Patient", name=[{"family": "Test"}]).save()
244+
patients = await aidbox_client.resources("Patient").fetch_all()
245+
assert len(patients) >= 1
246+
# after the test, safe_db rolls back and the patient is not persisted
247+
```
248+
249+
### Subscription trigger helper (`was_subscription_triggered`)
250+
251+
Use **`sdk.was_subscription_triggered(entity)`** (or `was_subscription_triggered_n_times(entity, n)`) only together with the **`safe_db`** fixture. Without `safe_db`, subscription handling is skipped for the test and the returned future is never completed, so the test will hang until the timeout.
252+
253+
Example:
254+
236255
```python
237256
@pytest.mark.asyncio
238257
async def test_patient_subscription(aidbox_client, safe_db, sdk):

0 commit comments

Comments
 (0)