From 56f1e7a6231a3e3c8eb46edceb1feaf2951f18d6 Mon Sep 17 00:00:00 2001 From: Ryan P Date: Thu, 21 May 2020 19:44:42 -0400 Subject: [PATCH] Remove AvroSerializer from __init__ in root package (#861) --- confluent_kafka/__init__.py | 2 +- .../schema_registry/data/logical_date.avsc | 13 +++++++++++++ .../integration/schema_registry/test_api_client.py | 13 +++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/integration/schema_registry/data/logical_date.avsc diff --git a/confluent_kafka/__init__.py b/confluent_kafka/__init__.py index fa0e2cafd..e8e5cc30c 100644 --- a/confluent_kafka/__init__.py +++ b/confluent_kafka/__init__.py @@ -34,7 +34,7 @@ OFFSET_STORED, OFFSET_INVALID) -__all__ = ['admin', 'AvroSerializer', 'Consumer', +__all__ = ['admin', 'Consumer', 'KafkaError', 'KafkaException', 'kafkatest', 'libversion', 'Message', 'OFFSET_BEGINNING', 'OFFSET_END', 'OFFSET_INVALID', 'OFFSET_STORED', diff --git a/tests/integration/schema_registry/data/logical_date.avsc b/tests/integration/schema_registry/data/logical_date.avsc new file mode 100644 index 000000000..b1a7aa592 --- /dev/null +++ b/tests/integration/schema_registry/data/logical_date.avsc @@ -0,0 +1,13 @@ +{ + "name": "a_schema", + "type": "record", + "fields": [ + { + "name": "date_field", + "type": { + "type": "int", + "logicalType": "date" + } + } + ] +} diff --git a/tests/integration/schema_registry/test_api_client.py b/tests/integration/schema_registry/test_api_client.py index e97295489..95e253c66 100644 --- a/tests/integration/schema_registry/test_api_client.py +++ b/tests/integration/schema_registry/test_api_client.py @@ -416,3 +416,16 @@ def test_api_config_update(kafka_cluster): for level in ["BACKWARD", "BACKWARD_TRANSITIVE", "FORWARD", "FORWARD_TRANSITIVE"]: sr.set_compatibility(level=level) assert sr.get_compatibility()['compatibilityLevel'] == level + + +def test_api_register_logical_schema(kafka_cluster, load_file): + sr = kafka_cluster.schema_registry() + + schema = Schema(load_file('logical_date.avsc'), schema_type='AVRO') + subject = _subject_name('test_logical_registration') + + schema_id = sr.register_schema(subject, schema) + registered_schema = sr.lookup_schema(subject, schema) + + assert registered_schema.schema_id == schema_id + assert registered_schema.subject == subject