Uh oh!
There was an error while loading. Please reload this page.
Conversation
tswast
commented
May 1, 2017
I'll fix up the lint errors in a change I'm making that adds some tests. |
theacodes
commented
May 2, 2017
@tswast SG, just ping when you're ready for review. |
tswast
commented
May 2, 2017
@jonparrott Okay, ready for review. I added tests that mock out the flow using a service account like we discussed in chat. |
There was a problem hiding this comment.
I'd be great to not have this in the repository, is there any reason for it?
There was a problem hiding this comment.
Removed.
Not needed after I changed the tests to mock out user credentials. I'll make sure the docs say to put such a file here.
There was a problem hiding this comment.
auth_query doesn't ring well to me as a good name. Maybe authenticate_and_query?
There was a problem hiding this comment.
you can use py.test's monkeypatch fixture for this or decorate with @mock.patch('google_auth_oauthlib.flow.InstalledAppFlow', new=MockFlow).
There was a problem hiding this comment.
Better yet, I'd actually prefer you to write a new fixture for this using Mock's autospec. This will ensure that even if google-auth-oauthlib's API changes, our test will catch the interface change despite the mocking:
@pytest.fixturedefmock_flow():
flow_patch=mock.patch('google_oauthlib_flow.InstalledAppFlow', autospec=True)
withflow_patchasflow_mock:
flow_mock.credentials=google.auth.default()[0]
yieldflow_mockThere was a problem hiding this comment.
Done, autospec is quite cool.
There was a problem hiding this comment.
No need for this test. We're really not after exhaustive coverage.
Mocks out user credentials using the Application Default Credentials, but uses the same scopes.
theacodes
commented
May 3, 2017
Thanks for doing this, @tswast! |
…loudPlatform/python-docs-samples#925) * BigQuery: user credentials to run a query. * BigQuery user creds sample: add tests. Mocks out user credentials using the Application Default Credentials, but uses the same scopes.
…loudPlatform/python-docs-samples#925) * BigQuery: user credentials to run a query. * BigQuery user creds sample: add tests. Mocks out user credentials using the Application Default Credentials, but uses the same scopes.
…rm/python-docs-samples#925) * BigQuery: user credentials to run a query. * BigQuery user creds sample: add tests. Mocks out user credentials using the Application Default Credentials, but uses the same scopes.
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
…ours in export_test.py (#925) * chore: Running this to remove all sinks * readd try block * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * added timestamp to sink name * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Fixed regex string * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
…ours in export_test.py (#925) * chore: Running this to remove all sinks * readd try block * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * added timestamp to sink name * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Fixed regex string * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
I'm not sure how to test this one.
Is it possible to add tests that only run locally not on Jenkins, Travis, or Circle?