Skip to content

Commit

Permalink
chore: remove unnecessary trail for test paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaakola-aiven committed Dec 18, 2024
1 parent ff29e64 commit 7969dc8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
6 changes: 2 additions & 4 deletions tests/e2e/schema_registry/test_jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,12 @@ async def not_schemas_are_backward_compatible(
)


@pytest.mark.parametrize("trail", ["", "/"])
@pytest.mark.parametrize("compatibility", [CompatibilityModes.FORWARD, CompatibilityModes.BACKWARD, CompatibilityModes.FULL])
@pytest.mark.parametrize("metadata", [None, {}])
@pytest.mark.parametrize("rule_set", [None, {}])
async def test_same_jsonschema_must_have_same_id(
registry_async_client: Client,
compatibility: CompatibilityModes,
trail: str,
metadata: SchemaMetadata,
rule_set: SchemaRuleSet,
) -> None:
Expand All @@ -251,7 +249,7 @@ async def test_same_jsonschema_must_have_same_id(
assert res.status_code == 200

first_res = await registry_async_client.post(
f"subjects/{subject}/versions{trail}",
f"subjects/{subject}/versions",
json={
"schema": json.dumps(schema.schema),
"schemaType": SchemaType.JSONSCHEMA.value,
Expand All @@ -264,7 +262,7 @@ async def test_same_jsonschema_must_have_same_id(
assert first_id

second_res = await registry_async_client.post(
f"subjects/{subject}/versions{trail}",
f"subjects/{subject}/versions",
json={
"schema": json.dumps(schema.schema),
"schemaType": SchemaType.JSONSCHEMA.value,
Expand Down
31 changes: 13 additions & 18 deletions tests/integration/test_schema_protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ def add_slashes(text: str) -> str:

# This test ProtoBuf schemas in subject registeration, compatibility of evolved version and querying the schema
# w.r.t. normalization of whitespace and other minor differences to verify equality and inequality comparison of such schemas
@pytest.mark.parametrize("trail", ["", "/"])
@pytest.mark.parametrize("registry_cluster", [{"config": {}}, {"config": {"use_protobuf_formatter": True}}], indirect=True)
async def test_protobuf_schema_normalization(registry_async_client: Client, trail: str) -> None:
subject = create_subject_name_factory(f"test_protobuf_schema_compatibility-{trail}")()
async def test_protobuf_schema_normalization(registry_async_client: Client) -> None:
subject = create_subject_name_factory("test_protobuf_schema_compatibility")()

res = await registry_async_client.put(f"config/{subject}{trail}", json={"compatibility": "BACKWARD"})
res = await registry_async_client.put(f"config/{subject}", json={"compatibility": "BACKWARD"})
assert res.status_code == 200

original_schema = """
Expand Down Expand Up @@ -91,36 +90,34 @@ async def test_protobuf_schema_normalization(registry_async_client: Client, trai
)

res = await registry_async_client.post(
f"subjects/{subject}/versions{trail}", json={"schemaType": "PROTOBUF", "schema": original_schema}
f"subjects/{subject}/versions", json={"schemaType": "PROTOBUF", "schema": original_schema}
)
assert res.status_code == 200
assert "id" in res.json()
original_id = res.json()["id"]

res = await registry_async_client.post(
f"subjects/{subject}/versions{trail}", json={"schemaType": "PROTOBUF", "schema": original_schema}
f"subjects/{subject}/versions", json={"schemaType": "PROTOBUF", "schema": original_schema}
)
assert res.status_code == 200
assert "id" in res.json()
assert original_id == res.json()["id"], "No duplication"

res = await registry_async_client.post(
f"subjects/{subject}/versions{trail}", json={"schemaType": "PROTOBUF", "schema": original_schema_with_whitespace}
f"subjects/{subject}/versions", json={"schemaType": "PROTOBUF", "schema": original_schema_with_whitespace}
)
assert res.status_code == 200
assert "id" in res.json()
assert original_id == res.json()["id"], "No duplication with whitespace differences"

res = await registry_async_client.post(
f"subjects/{subject}{trail}", json={"schemaType": "PROTOBUF", "schema": original_schema}
)
res = await registry_async_client.post(f"subjects/{subject}", json={"schemaType": "PROTOBUF", "schema": original_schema})
assert res.status_code == 200
assert "id" in res.json()
assert "schema" in res.json()
assert original_id == res.json()["id"], "Check returns original id"

res = await registry_async_client.post(
f"subjects/{subject}{trail}", json={"schemaType": "PROTOBUF", "schema": original_schema_with_whitespace}
f"subjects/{subject}", json={"schemaType": "PROTOBUF", "schema": original_schema_with_whitespace}
)
assert res.status_code == 200
assert "id" in res.json()
Expand All @@ -146,36 +143,34 @@ async def test_protobuf_schema_normalization(registry_async_client: Client, trai
evolved_schema = trim_margin(evolved_schema)

res = await registry_async_client.post(
f"compatibility/subjects/{subject}/versions/latest{trail}",
f"compatibility/subjects/{subject}/versions/latest",
json={"schemaType": "PROTOBUF", "schema": evolved_schema},
)
assert res.status_code == 200
assert res.json() == {"is_compatible": True}

res = await registry_async_client.post(
f"subjects/{subject}/versions{trail}", json={"schemaType": "PROTOBUF", "schema": evolved_schema}
f"subjects/{subject}/versions", json={"schemaType": "PROTOBUF", "schema": evolved_schema}
)
assert res.status_code == 200
assert "id" in res.json()
assert original_id != res.json()["id"], "Evolved is not equal"
evolved_id = res.json()["id"]

res = await registry_async_client.post(
f"compatibility/subjects/{subject}/versions/latest{trail}",
f"compatibility/subjects/{subject}/versions/latest",
json={"schemaType": "PROTOBUF", "schema": original_schema},
)
assert res.json() == {"is_compatible": True}
assert res.status_code == 200
res = await registry_async_client.post(
f"subjects/{subject}/versions{trail}", json={"schemaType": "PROTOBUF", "schema": original_schema}
f"subjects/{subject}/versions", json={"schemaType": "PROTOBUF", "schema": original_schema}
)
assert res.status_code == 200
assert "id" in res.json()
assert original_id == res.json()["id"], "Original id again"

res = await registry_async_client.post(
f"subjects/{subject}{trail}", json={"schemaType": "PROTOBUF", "schema": evolved_schema}
)
res = await registry_async_client.post(f"subjects/{subject}", json={"schemaType": "PROTOBUF", "schema": evolved_schema})
assert res.status_code == 200
assert "id" in res.json()
assert "schema" in res.json()
Expand Down

0 comments on commit 7969dc8

Please sign in to comment.