Created
August 15, 2019 20:34
-
-
Save jonathansick/55da98366712cd77b897b498e565f154 to your computer and use it in GitHub Desktop.
Using the MockRegistryApi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In unit tests ===================================== | |
from kafkit.registry.sansio import MockRegistryApi | |
# The Avro schema that you'll be testing with | |
schema = {} | |
# The MockRegistryApi works just like the RegistryApi, but doesn't | |
# do any network requests. | |
registryclient = MockRegistryApi() | |
# Insert the schema you know you're using into the client's | |
# cache. The `1` is just the unique ID that the Confluent Schema | |
# Registry server would have assigned to it. | |
registryclient.schemas.insert(schema, 1) | |
# In the application code ============================= | |
# Now you can pass this registryclient into the code being | |
# tested and it will work without any network I/O. | |
# The serializer can now use this registry. When it does | |
serializer = await Serializer.register( | |
registry=client, | |
schema=schema) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment