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

Assert expected_params stubber #784

Merged
merged 4 commits into from
Feb 8, 2016
Merged

Conversation

kyleknap
Copy link
Contributor

@kyleknap kyleknap commented Feb 2, 2016

Allows you to specify what parameters that you are to expect for a response and if they do not match, throw an error.

I have been writing a fair amount of tests using this stubber. I have found this sort of response/expected_params matching as being pretty useful and was using it an awful lot.

The only behavior I am not sure about and would be up for opinions is what happens to the stubber's corresponding response when an expected_params does not match. Should it use up the response in the queue? Or should it keep the original response in the queue so that it can be called later? I decided to go with the later because in the current stubber logic if there is a parameter validation error with the client, we will not pop the response off of the queue. So I thought expected_params would have a similar expectation.

cc @jamesls @mtdowling @rayluo @JordonPhillips

Allows you to specify what parameters that you are to expect for a response
and if they do not match, throw an error.
@mtdowling
Copy link
Contributor

Nice! 🚢

I decided to go with the later because in the current stubber logic if there is a parameter validation error with the client, we will not pop the response off of the queue.

Seems reasonable. It probably won't matter much in practice -- once a mismatch occurs, an exception is thrown and the test will likely halt at that point.

@@ -154,7 +176,13 @@ def add_client_error(self, method, service_error_code='',
}

operation_name = self.client.meta.method_to_api_mapping.get(method)
response = (operation_name, (http_response, parsed_response))
# Note that we do not allow for expected_params in the
# adding errors into the queue yet.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would replace 'in the' with 'while'.

@JordonPhillips
Copy link
Contributor

⛵ Nice!

@jamesls
Copy link
Member

jamesls commented Feb 8, 2016

:shipit:

kyleknap added a commit that referenced this pull request Feb 8, 2016
Assert ``expected_params`` stubber
@kyleknap kyleknap merged commit 05912d4 into boto:develop Feb 8, 2016
@kyleknap kyleknap deleted the assert-stubber branch February 8, 2016 23:13
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.

4 participants