-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Add samples for auth #969
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 samples for auth #969
Conversation
|
|
||
| # Make an authenticated API request | ||
| buckets = storage_client.buckets().list(project=project).execute() | ||
| print(buckets) |
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.
Normally I'd "from future import print_function" in a file that uses print(), even if this technically works in 2.7 as-is. Do we have an explicit policy on 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.
We don't, and generally because we use .format is isn't ever explicitly needed to use print_function.
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.
Okay, my preference is to include the import because print with parens is confusing syntax in Py2, but I'll leave it to you.
| import snippets | ||
|
|
||
|
|
||
| def test_implicit(): |
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.
I am confused about the structure of these tests; is there part of this (that does assertions etc) I'm missing?
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.
It's a system test, in this case an absence of an error is the assertion. We could technically capture the output and assert that it matches some idea of what we think the output should be, but it doesn't necessarily add any value.
|
|
||
| def implicit(): | ||
| import google.auth | ||
| from google.auth.transport import requests |
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.
Why do we do these imports inside the function? And why do we have a vendored requests version?
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.
Because when these are included in the documentation it will only include the body of this function.
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.
Okay, this strikes me as a bit confusing when you're reading the actual file, but not a big deal.
No description provided.