diff --git a/tests/unit/routes/test_seed_router.py b/tests/unit/routes/test_seed_router.py index c3c7e42c..992ff586 100644 --- a/tests/unit/routes/test_seed_router.py +++ b/tests/unit/routes/test_seed_router.py @@ -19,7 +19,8 @@ def setup_class(cls): pytest.skip("Test skipped because the database dialect is not MySQL") def test_mysql_not_supported(self, client, session): - response = client.post("/seed", json={"clusters": []}) + data = {"clusters": [{"records": []} for _ in range(10)]} + response = client.post("/seed", json=data) assert response.status_code == 422 assert response.json() == {"detail": "Batch seeding is not supported for MySQL"} @@ -30,6 +31,17 @@ def setup_class(cls): if db_dialect() == "mysql": pytest.skip("Test skipped because the database dialect is MySQL") + def test_empty_clusters(self, client): + response = client.post("/seed", json={"clusters": []}) + assert response.status_code == 422 + assert response.json()["detail"][0]["msg"] == "Value error, Clusters must not be empty" + + def test_too_many_clusters(self, client): + data = {"clusters": [{"records": []} for _ in range(101)]} + response = client.post("/seed", json=data) + assert response.status_code == 422 + assert response.json()["detail"][0]["msg"] == "Value error, Clusters must not exceed 100 records" + def test_large_batch(self, client): data = load_test_json_asset("seed_test.json.gz") response = client.post("/seed", json=data) diff --git a/tests/unit/schemas/test_pii.py b/tests/unit/schemas/test_pii.py index 47b0f5d2..d97ba815 100644 --- a/tests/unit/schemas/test_pii.py +++ b/tests/unit/schemas/test_pii.py @@ -368,10 +368,15 @@ def test_blocking_values(self): "name": [{"given": ["John", "William"], "family": "Doe"}], } ) - assert list(rec.blocking_values()) == [ - (BlockingKey.BIRTHDATE, "1980-01-01"), - (BlockingKey.MRN, "3456"), - (BlockingKey.FIRST_NAME, "John"), - (BlockingKey.FIRST_NAME, "Will"), - (BlockingKey.LAST_NAME, "Doe"), - ] + + for key, val in rec.blocking_values(): + if key == BlockingKey.BIRTHDATE: + assert val == "1980-01-01" + elif key == BlockingKey.MRN: + assert val == "3456" + elif key == BlockingKey.FIRST_NAME: + assert val in ("John", "Will") + elif key == BlockingKey.LAST_NAME: + assert val == "Doe" + else: + raise AssertionError(f"Unexpected key: {key}")