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

Add a test of metadata, status code, and details #6955

Merged

Conversation

nathanielmanistaatgoogle
Copy link
Member

Fixes issue 4545.

Please pay particular attention to the way .decode('utf-8') is used on strings; please feel free to say "oh no I see what you're going for but the better way is <...>".

@thunderboltsid
Copy link
Member

thunderboltsid commented Jun 21, 2016

I don't see a problem with the way decode is used. The other option is using python struct library and do struct.unpack(...) but this is definitely not necessary here.


def __init__(self, channel):
unary_unary = channel.unary_unary(
b''.join((b'/', _SERVICE, b'/', _UNARY_UNARY,)),
Copy link
Contributor

Choose a reason for hiding this comment

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

b'/'.join(b'', _SERVICE , _UNARY_UNARY) seems to accomplish this a bit more eloquently.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed; done.

@nathanielmanistaatgoogle
Copy link
Member Author

(The content of this pull request has now also undergone a with_call=Truemulti_callable.with_call conversion.)

@kpayson64
Copy link
Contributor

Lgtm

@jcanizales
Copy link
Contributor

To clarify, because I've become a bit unfamiliar with the Python API: where in the tests are error details being set by the server, and where are they read by the client? (Maybe we can add a comment?)

@nathanielmanistaatgoogle nathanielmanistaatgoogle deleted the metadata-code-details branch June 23, 2016 18:08
@nathanielmanistaatgoogle
Copy link
Member Author

@jcanizales: the code is set in a call to ServicerContext.set_code (such as this one), the details are set in a call to ServicerContext.set_details (such as this one), the code is read in a call to Call.code (such as this one), and the details are read in a call to Call.details (such as this one).

@jcanizales
Copy link
Contributor

jcanizales commented Jun 23, 2016

Oh! You're talking "details" as in "error message". The original issue was about extra error details that would be transmitted as protos, serialized in the server and parsed by the client, for programmatic handling. Sorry that that wasn't clear.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 27, 2019
@lock lock bot unassigned soltanmm Jan 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants