-
Notifications
You must be signed in to change notification settings - Fork 125
Explicit auth tests #170
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
Closed
Closed
Explicit auth tests #170
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
c85a685
project_id is optional
max-sixty 8786e6d
Merge branch 'master' into default-project
max-sixty 17a2ede
gitignore
max-sixty 86b6fc5
docstring
max-sixty 11c146e
don't skip if no project
max-sixty 817c63a
formatting
max-sixty f0a8d36
add marks to allow test selecting
max-sixty 4ecfcfc
assign mark to test
max-sixty c402952
explicitly chose with auth to do from travis
max-sixty 476bcf1
too hasty to change the pandas installation
max-sixty ef59bca
do what needs doing
max-sixty 2112acd
Fixing style errors.
stickler-ci 6cc99f6
docstring & import order
max-sixty 56436ff
correct mark expression
max-sixty 5347858
project not required only if default creds available
max-sixty cd9b37d
remove any more branching in travis
max-sixty fa97b0f
Merge branch 'master' of https://github.com/pydata/pandas-gbq into de…
max-sixty a7f6c43
google import inline
max-sixty 0b9b033
Merge branch 'master' into explicit-tests
max-sixty dd5893a
fixes
max-sixty fddd57f
quote characters
max-sixty b76e4c2
Move user auth skip to just user auth tests.
tswast d4d10ac
Use verbose tests to see which test timeouts on Travis.
tswast File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,11 +23,6 @@ | |
TABLE_ID = 'new_test' | ||
|
||
|
||
def _skip_local_auth_if_in_travis_env(): | ||
if _in_travis_environment(): | ||
pytest.skip("Cannot run local auth in travis environment") | ||
|
||
|
||
def _skip_if_no_private_key_path(): | ||
if not _get_private_key_path(): | ||
pytest.skip("Cannot run integration tests without a " | ||
|
@@ -172,6 +167,26 @@ def test_generate_bq_schema_deprecated(): | |
gbq.generate_bq_schema(df) | ||
|
||
|
||
@pytest.fixture(params=[ | ||
pytest.param('local', marks=pytest.mark.local_auth), | ||
pytest.param('service_path', marks=pytest.mark.s_path_auth), | ||
pytest.param('service_creds', marks=pytest.mark.s_cred_auth), | ||
]) | ||
def auth_type(request): | ||
|
||
auth = request.param | ||
|
||
if auth == 'local': | ||
pass | ||
elif auth == 'service_path': | ||
_skip_if_no_private_key_path() | ||
elif auth == 'service_creds': | ||
_skip_if_no_private_key_contents() | ||
else: | ||
raise ValueError | ||
return auth | ||
|
||
|
||
@pytest.fixture() | ||
def credentials(): | ||
_skip_if_no_private_key_contents() | ||
|
@@ -205,6 +220,7 @@ def test_should_be_able_to_get_results_from_query(self, gbq_connector): | |
assert pages is not None | ||
|
||
|
||
@pytest.mark.local_auth | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like |
||
class TestAuth(object): | ||
|
||
@pytest.fixture(autouse=True) | ||
|
@@ -236,15 +252,13 @@ def test_get_application_default_credentials_returns_credentials(self): | |
assert default_project is not None | ||
|
||
def test_get_user_account_credentials_bad_file_returns_credentials(self): | ||
_skip_local_auth_if_in_travis_env() | ||
|
||
from google.auth.credentials import Credentials | ||
with mock.patch('__main__.open', side_effect=IOError()): | ||
credentials = self.sut.get_user_account_credentials() | ||
assert isinstance(credentials, Credentials) | ||
|
||
def test_get_user_account_credentials_returns_credentials(self): | ||
_skip_local_auth_if_in_travis_env() | ||
|
||
from google.auth.credentials import Credentials | ||
credentials = self.sut.get_user_account_credentials() | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Looks like unit tests got included twice.