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

Refactore HttpClient and HttpFuture #127

Merged
merged 8 commits into from
Mar 28, 2015
Merged

Conversation

prat0318
Copy link
Contributor

Pending:

  • I have yet to write more unit tests to it, but did not want the PR to get more bulkier.
  • More functional tests.

Conflicts:
	bravado/client.py
	bravado/mapping/operation.py
	docs/source/quickstart.rst
	tests/client_test.py
return fido.fetch(url, **request_params)
fido_future = FidoFuture(op, url, request_params)
fido_future.fetch()
return fido_future
Copy link
Contributor

Choose a reason for hiding this comment

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

docstring and return type don't match. Also add op to docstring

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack.

@analogue
Copy link
Contributor

lgtm except for the minor stuff

"""

def start_request(self, request_params):
def request(self, request_params, op=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Since operation is required, I would make it a regular argument, not a kwarg.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is because op is not required for api-docs fetch. For that instance, client.request(request_params) has to be called without op.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, ok, fair enough, kwargs works

@dnephin
Copy link
Contributor

dnephin commented Mar 23, 2015

This is looks good, I think with a few more small changes we can remove the mutability and inheritance as well


# op is not present during api-docs fetch, return raw response
if not self.op:
return response
Copy link
Contributor

Choose a reason for hiding this comment

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

I think having very different responses based on the presence of an operation is kind of unexpected.

I also just noticed that self.op is only being used the unmarshal the response.

It seems like this interface would be much more concise if unmarshal_response(response, op) were actually called by whatever calls this.

That would allow us to remove self.op as a parameter entirely.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ya, I think we can accomplish this by restoring handle_response(response, op), but without any of the branch logic. Since the adapters normalize the response to a single representation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack.

Conflicts:
	bravado/mapping/operation.py
	tests/mapping/operation/unmarshal_response_test.py
	tests/resource_response_test.py
@prat0318
Copy link
Contributor Author

  • Refactored to re-introduce callbacks.
  • Made HttpFuture as a class instead of an interface.

@analogue I saw that in the integration tests, .body and .text are expected from the result but the ResponseLike only exposes .json and .status_code. I am not sure why it was not throwing up earlier, but now the tests throw No attribute present body etc.

Also, functional tests fail with jsonschema validation failure of parameter count being 0.

:type response_adapter: :class: `bravado.mapping.response.ResponseLike`
:param callback: Function to be called on the response
"""
self.request_adapter = request_adapter
Copy link
Contributor

Choose a reason for hiding this comment

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

s/request_adapter/future/ , since the interface is concurrent.futures.Future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

@dnephin
Copy link
Contributor

dnephin commented Mar 25, 2015

This looks great! Thanks for making all the changes. Just some minor rename/docstring stuff left

@prat0318
Copy link
Contributor Author

@analogue I am adding text property to requests and fido adapters which contain the raw response from the server. This is to make the new integration tests pass. It is kinda other way round (to make the tests pass), but i think it is ok to have a raw response option available to the client.

@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like there are some remaining

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the line: #!/usr/bin/env python.
Shouldn't we define the python encoding as utf-8 instead of default ascii as the best practice?

@analogue
Copy link
Contributor

ResponseLike needs to updated to support the text attr

@analogue
Copy link
Contributor

lgtm! good job

prat0318 added a commit that referenced this pull request Mar 28, 2015
Refactor HttpClient and HttpFuture
@prat0318 prat0318 merged commit 3b84db2 into Yelp:swagger2.0 Mar 28, 2015
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.

None yet

3 participants