Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-40638: Fix serialization of objects in watch events #197

Merged
merged 3 commits into from
Sep 7, 2023
Merged

Conversation

rra
Copy link
Member

@rra rra commented Sep 7, 2023

In the Kubernetes mock, objects serialized into watch events were not being serialized properly. They were keeping the Python snake-case attribute names instead of the Kubernetes camel-case names. This prevented deserialization to Kubernetes model objects and was also confusing.

Fix this by passing the serialize parameter to to_dict when serializing the objects, and restructure the code a bit to reduce duplicate work. Add an explicit test for proper object serialization and deserialization.

When mocking the Kubernetes API, stop mocking the entire ApiClient, since we need to use its deserialize method to convert watch events to their proper types. Due to the other mocking, we should never make network calls, but mock the request method of ApiClient just in case.

rra added 3 commits September 7, 2023 15:52
When mocking the Kubernetes API, stop mocking the entire ApiClient,
since we need to use its deserialize method to convert watch events
to their proper types. Due to the other mocking, we should never
make network calls, but mock the request method of ApiClient just
in case.
In the Kubernetes mock, objects serialized into watch events were
not being serialized properly. They were keeping the Python
snake-case attribute names instead of the Kubernetes camel-case
names. This prevented deserialization to Kubernetes model objects
and was also confusing.

Fix this by passing the serialize parameter to to_dict when
serializing the objects, and restructure the code a bit to reduce
duplicate work. Add an explicit test for proper object serialization
and deserialization.
Update the documentation for watches and mention passing the type
of the model explicitly into the Watch constructor. Mention the
serialize parameter to the to_dict method. Add a change log entry
for Kubernetes mock fixes.
@rra rra merged commit aede45c into main Sep 7, 2023
5 checks passed
@rra rra deleted the tickets/DM-40638 branch September 7, 2023 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant