Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,13 @@ async def register_schema_full_response(
if schema_id is not None:
result = self._cache.get_schema_by_id(subject_name, schema_id)
if result is not None:
return RegisteredSchema(schema_id, result[0], result[1], subject_name, None)
return RegisteredSchema(
schema_id=schema_id,
guid=result[0],
subject=subject_name,
version=None,
schema=result[1]
)

request = schema.to_dict()

Expand All @@ -682,7 +688,7 @@ async def register_schema_full_response(
guid=result.guid,
subject=result.subject or subject_name,
version=result.version,
schema=result.schema,
schema=result.schema
)

# The registered schema may not be fully populated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,13 @@ def register_schema_full_response(
if schema_id is not None:
result = self._cache.get_schema_by_id(subject_name, schema_id)
if result is not None:
return RegisteredSchema(schema_id, result[0], result[1], subject_name, None)
return RegisteredSchema(
schema_id=schema_id,
guid=result[0],
subject=subject_name,
version=None,
schema=result[1]
)

request = schema.to_dict()

Expand All @@ -682,7 +688,7 @@ def register_schema_full_response(
guid=result.guid,
subject=result.subject or subject_name,
version=result.version,
schema=result.schema,
schema=result.schema
)

# The registered schema may not be fully populated
Expand Down
11 changes: 11 additions & 0 deletions tests/schema_registry/_async/test_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,23 @@
async def test_register_schema(mock_schema_registry, load_avsc):
conf = {'url': TEST_URL}
sr = AsyncSchemaRegistryClient(conf)
schema = Schema(load_avsc('basic_schema.avsc'), schema_type='AVRO')

Check failure on line 84 in tests/schema_registry/_async/test_api_client.py

View check run for this annotation

SonarQube-Confluent / confluent-kafka-python Sonarqube Results

tests/schema_registry/_async/test_api_client.py#L84

Define a constant instead of duplicating this literal 'basic_schema.avsc' 9 times.

result = await sr.register_schema('test-key', schema)
assert result == SCHEMA_ID


async def test_register_schema_full_response_recall(mock_schema_registry, load_avsc):
conf = {'url': TEST_URL}
sr = AsyncSchemaRegistryClient(conf)
schema = Schema(load_avsc('basic_schema.avsc'), schema_type='AVRO')

await sr.register_schema('test-key', schema)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this line be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's intended to force the cache load of an already registered schema for the test


result = await sr.register_schema_full_response('test-key', schema)
assert result.schema_id == SCHEMA_ID


async def test_register_schema_incompatible(mock_schema_registry, load_avsc):
conf = {'url': TEST_URL}
sr = AsyncSchemaRegistryClient(conf)
Expand Down
11 changes: 11 additions & 0 deletions tests/schema_registry/_sync/test_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,23 @@
def test_register_schema(mock_schema_registry, load_avsc):
conf = {'url': TEST_URL}
sr = SchemaRegistryClient(conf)
schema = Schema(load_avsc('basic_schema.avsc'), schema_type='AVRO')

Check failure on line 84 in tests/schema_registry/_sync/test_api_client.py

View check run for this annotation

SonarQube-Confluent / confluent-kafka-python Sonarqube Results

tests/schema_registry/_sync/test_api_client.py#L84

Define a constant instead of duplicating this literal 'basic_schema.avsc' 9 times.

result = sr.register_schema('test-key', schema)
assert result == SCHEMA_ID


def test_register_schema_full_response_recall(mock_schema_registry, load_avsc):
conf = {'url': TEST_URL}
sr = SchemaRegistryClient(conf)
schema = Schema(load_avsc('basic_schema.avsc'), schema_type='AVRO')

sr.register_schema('test-key', schema)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same


result = sr.register_schema_full_response('test-key', schema)
assert result.schema_id == SCHEMA_ID


def test_register_schema_incompatible(mock_schema_registry, load_avsc):
conf = {'url': TEST_URL}
sr = SchemaRegistryClient(conf)
Expand Down