Skip to content

Commit 779676f

Browse files
Merge pull request #677 from aiven/eliax1996/split-test-responsibility
tests: splitted responsibility of a test with multiple testing purpos…
2 parents be70904 + d7b8f23 commit 779676f

1 file changed

Lines changed: 43 additions & 7 deletions

File tree

tests/integration/test_schema.py

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,49 @@ async def test_schema_repost(registry_async_client: Client, trail: str) -> None:
13351335
assert schema_id == res.json()["id"]
13361336

13371337

1338+
async def test_get_schema_with_subjects(registry_async_client: Client) -> None:
1339+
subject1 = create_subject_name_factory("subject_1")()
1340+
subject2 = create_subject_name_factory("subject_2")()
1341+
1342+
field_name = create_field_name_factory("field")()
1343+
schema_str = json.dumps({"type": "string", "unique": field_name})
1344+
res = await registry_async_client.post(
1345+
f"subjects/{subject1}/versions",
1346+
json={"schema": schema_str},
1347+
)
1348+
assert res.status_code == 200
1349+
assert "id" in res.json()
1350+
schema_id = res.json()["id"]
1351+
1352+
res = await registry_async_client.get(f"schemas/ids/{schema_id}")
1353+
assert res.ok
1354+
expected_schema = json.loads(schema_str)
1355+
1356+
json_reply = res.json()
1357+
assert "subjects" not in json_reply, "the default reply shouldn't include the subjects field"
1358+
assert json.loads(json_reply["schema"]) == expected_schema
1359+
1360+
res = await registry_async_client.get(f"schemas/ids/{schema_id}", params={"includeSubjects": "True"})
1361+
assert res.ok
1362+
json_reply = res.json()
1363+
1364+
assert json.loads(json_reply["schema"]) == expected_schema, "schema should always stays the same"
1365+
assert json_reply["subjects"] == [subject1], "subjects should be present if specified"
1366+
1367+
res = await registry_async_client.post(
1368+
f"subjects/{subject2}/versions",
1369+
json={"schema": schema_str},
1370+
)
1371+
assert res.status_code == 200
1372+
1373+
res = await registry_async_client.get(f"schemas/ids/{schema_id}", params={"includeSubjects": "True"})
1374+
assert res.ok
1375+
json_reply = res.json()
1376+
1377+
assert json.loads(json_reply["schema"]) == expected_schema, "schema should always stays the same"
1378+
assert json_reply["subjects"] == [subject1, subject2], "subjects should be present if specified"
1379+
1380+
13381381
@pytest.mark.parametrize("trail", ["", "/"])
13391382
async def test_schema_missing_body(registry_async_client: Client, trail: str) -> None:
13401383
subject = create_subject_name_factory(f"test_schema_missing_body-{trail}")()
@@ -2355,13 +2398,6 @@ async def test_malformed_kafka_message(
23552398
expected_payload = {"schema": json_encode({"foo": "bar"}, compact=True)}
23562399
assert res_data == expected_payload, res_data
23572400

2358-
with_subjects_reply = await registry_async_client.get(path, params={"includeSubjects": "True"})
2359-
assert with_subjects_reply.ok, "a subsequent request once the server is up should be valid"
2360-
json_reply = with_subjects_reply.json()
2361-
assert "subjects" in json_reply, "subjects should be present if specified"
2362-
expected_payload["subjects"] = ["foo"]
2363-
assert expected_payload == json_reply, "the reply should be equal as the previous one with additional subjects field"
2364-
23652401

23662402
async def test_inner_type_compat_failure(registry_async_client: Client) -> None:
23672403
subject = create_subject_name_factory("test_inner_type_compat_failure")()

0 commit comments

Comments
 (0)