Add check for dict in serialize function #48
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This pull request introduces a change to the
serialize
function insmartsheet/util.py
to ensure that theadditionalDetails
property is correctly serialized when present in the response for the Event Reporting API.Changes:
Code Changes:
elif isinstance(obj, dict)
statement in theserialize
function to handle dictionary objects. This ensures that properties likeadditionalDetails
, which are dictionaries with an unknown number/type of key:value pairs, are correctly serialized and included in the output.Test Changes:
test_list_events
intests/integration/test_events.py
to include a check for theadditionalDetails
field. This test now verifies that whenadditionalDetails
is present, it is correctly populated and is of typedict
.Reason for Change:
The
additionalDetails
property was missing when querying Event Reporting. By adding theelif isinstance(obj, dict)
statement, we ensure that dictionary properties are handled properly during the serialization process, preserving the integrity of the API response.Testing:
additionalDetails
field is correctly serialized and populated when present in the response (sample outputs below).Sample output:
Without handling dicts during serialization:
With change to serialize dicts:
** Note: **
I believe this supersedes Salman's PR here -
additionalDetails
is still empty when querying when I tested with his change.