Skip to content
Open
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
2 changes: 1 addition & 1 deletion slack_sdk/scim/v1/internal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _convert_dict_keys(
)
result_dict[new_key].append(new_element)
else:
result_dict[new_key].append(_create_copy(original_value))
result_dict[new_key].append(_create_copy(element))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

praise: Nice catch, this is the right fix. Copying element instead of original_value keeps the list flat and leaves the list-of-dicts branch untouched.

else:
result_dict[new_key] = _create_copy(original_value)
return result_dict
Expand Down
4 changes: 4 additions & 0 deletions tests/slack_sdk/scim/test_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ def test_snake_cased(self):
result = _to_snake_cased(json.loads(response_body))
self.assertEqual(result["start_index"], 1)
self.assertIsNotNone(result["resources"][0]["id"])

def test_snake_cased_list_of_plain_values(self):
result = _to_snake_cased({"schemas": ["urn:scim:schemas:core:1.0", "urn:scim:schemas:extension:enterprise:1.0"]})
self.assertEqual(result["schemas"], ["urn:scim:schemas:core:1.0", "urn:scim:schemas:extension:enterprise:1.0"])
Comment thread
kwy404 marked this conversation as resolved.
Resolved
2 changes: 2 additions & 0 deletions tests/slack_sdk/scim/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def test_snake_cased(self):
)
)
user = response.users[0]
self.assertEqual(user.schemas, ["urn:scim:schemas:core:1.0"])
self.assertEqual(response.snake_cased_body["schemas"], ["urn:scim:schemas:core:1.0"])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

praise: Good call asserting on snake_cased_body["schemas"] here. It's the one that fails on main, and it's the same dict ReadUserResponse.user is built from, so the user-facing bug is pinned. 🙌

self.assertIsNotNone(user.unknown_fields.get("new_attribute"))
# the unknown fields need to be also camel-cased
self.assertIsNotNone(user.to_dict().get("newAttribute"))
Loading