-
Notifications
You must be signed in to change notification settings - Fork 40
Fix manager_user_id ValidationError by changing field type from StrictInt to StrictStr #102
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| # coding: utf-8 | ||
|
|
||
| """ | ||
| OneLogin API | ||
|
|
||
| OpenAPI Specification for OneLogin # noqa: E501 | ||
|
|
||
| The version of the OpenAPI document: 3.1.1 | ||
| Generated by OpenAPI Generator (https://openapi-generator.tech) | ||
|
|
||
| Do not edit the class manually. | ||
| """ | ||
|
|
||
|
|
||
| import unittest | ||
| import datetime | ||
|
|
||
| import onelogin | ||
| from onelogin.models.user import User # noqa: E501 | ||
| from onelogin.rest import ApiException | ||
|
|
||
|
|
||
| class TestUserManagerUserIdFix(unittest.TestCase): | ||
| """Test case for manager_user_id field fix (GitHub issue #100)""" | ||
|
|
||
| def setUp(self): | ||
| pass | ||
|
|
||
| def tearDown(self): | ||
| pass | ||
|
|
||
| def test_manager_user_id_with_string_value(self): | ||
| """ | ||
| Test that manager_user_id accepts string values from API response. | ||
| This test validates the fix for GitHub issue #100 where API returns | ||
| manager_user_id as string but model expected integer. | ||
| """ | ||
| user_data = { | ||
| "id": 123, | ||
| "username": "testuser", | ||
| "email": "test@example.com", | ||
| "manager_user_id": "252462756" # String value as returned by API | ||
| } | ||
|
|
||
| # This should work without validation errors | ||
| user = User.from_dict(user_data) | ||
| self.assertEqual(user.manager_user_id, "252462756") | ||
| self.assertIsInstance(user.manager_user_id, str) | ||
|
|
||
| def test_manager_user_id_with_none_value(self): | ||
| """ | ||
| Test that manager_user_id accepts None values. | ||
| """ | ||
| user_data = { | ||
| "id": 123, | ||
| "username": "testuser", | ||
| "email": "test@example.com", | ||
| "manager_user_id": None | ||
| } | ||
|
|
||
| user = User.from_dict(user_data) | ||
| self.assertIsNone(user.manager_user_id) | ||
|
|
||
| def test_manager_user_id_missing_field(self): | ||
| """ | ||
| Test that manager_user_id can be omitted (defaults to None). | ||
| """ | ||
| user_data = { | ||
| "id": 123, | ||
| "username": "testuser", | ||
| "email": "test@example.com" | ||
| # manager_user_id field is omitted | ||
| } | ||
|
|
||
| user = User.from_dict(user_data) | ||
| self.assertIsNone(user.manager_user_id) | ||
|
|
||
| def test_user_serialization_with_manager_user_id(self): | ||
| """ | ||
| Test that User can be serialized back to dict with manager_user_id. | ||
| """ | ||
| user_data = { | ||
| "id": 123, | ||
| "username": "testuser", | ||
| "email": "test@example.com", | ||
| "manager_user_id": "252462756" | ||
| } | ||
|
|
||
| user = User.from_dict(user_data) | ||
| user_dict = user.to_dict() | ||
|
|
||
| self.assertEqual(user_dict["manager_user_id"], "252462756") | ||
| self.assertIsInstance(user_dict["manager_user_id"], str) | ||
|
|
||
| def test_parse_obj_compatibility(self): | ||
| """ | ||
| Test that parse_obj method (used in API deserialization) works correctly. | ||
| This specifically tests the flow mentioned in the original issue traceback. | ||
| """ | ||
| user_data = { | ||
| "id": 123, | ||
| "username": "testuser", | ||
| "email": "test@example.com", | ||
| "manager_user_id": "252462756" | ||
| } | ||
|
|
||
| # This is the method called in the traceback from the original issue | ||
| user = User.parse_obj(user_data) | ||
| self.assertEqual(user.manager_user_id, "252462756") | ||
| self.assertIsInstance(user.manager_user_id, str) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() | ||
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.
Uh oh!
There was an error while loading. Please reload this page.