-
-
Notifications
You must be signed in to change notification settings - Fork 758
Fixed a bug where key value pair was not returning data correctly when get_by_name function is called. #5677
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
Fixed a bug where key value pair was not returning data correctly when get_by_name function is called. #5677
Conversation
Resubmitted the PR with correct credentials. |
Can anyone help me on how to add changes to CHANGELOG.rst? Do I need to run some command like |
@bharath-orchestral Thanks for working on this! Here is the changelog: https://github.com/StackStorm/st2/blob/master/CHANGELOG.rst For this PR, you will need to put your changelog entry under |
To run the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run black
on the files you've changed.
Also, I wonder if the code duplication can be reduced.
st2client/st2client/models/core.py
Outdated
if response.status_code != http_client.OK: | ||
self.handle_error(response) | ||
|
||
return self.resource.deserialize(parse_api_response(response)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs new line at EOF
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
st2client/tests/unit/test_models.py
Outdated
resource = mgr.get_by_name("abc") | ||
actual = resource.serialize() | ||
expected = json.loads(json.dumps(base.RESOURCES[0])) | ||
self.assertEqual(actual, expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line at EOF
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
Deleting that init.py file also removed the folders it was in, so now there are failures in some unit tests. Could you restore that please? Or a .gitkeep file would probably work |
I added that init.py in that folder but for some reason orquesta CI/ Integration Tests are failing. @cognifloyd Do you know the reason for this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky test. Oh, sand I just noticed the header in that empty __init__.py
. please don't add headers to empty __init__.py
files like that.
@@ -0,0 +1,14 @@ | |||
# Copyright 2020 The StackStorm Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__init__.py
should be empty unless there is logic in the file. Please delete all these headers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted all the headers. Now __init__.py
is empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, just one really small comment on the changelog
Bug: Calling 'get_by_name' on client for getting key details was not returning any results despite key being stored. Following is the sample code for replicating the bug
Resolution: 'keys' property in Client is of type 'ResourceManager'. We created a new class 'KeyValuePairResourceManager' which inherits from 'ResourceManager'. We assigned 'KeyValuePairResourceManager' to 'keys' property. We have created get_by_name in this class. KeyValuePairResourceManager's get_by_name calls "/keys/{keyname}" url while the old function used to call '/keys' url.
We looked into test cases for classes which inherit from 'ResourceManager' but did not find any. There are test cases
for functions in 'ResourceManager' but not for classes inheriting from it.
But we wrote a unit test case which tests KeyValuePairResourceManager's get_by_name function