Skip to content

Commit

Permalink
feat(test): add tests for the current behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanix-Darker committed Oct 2, 2023
1 parent a982faf commit e4453a2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/google_big_query/test_google_big_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,3 +852,31 @@ def test_optional_fields_validator_for_google_creds_or_jwt():
}
# no error raised
_ = GoogleBigQueryConnector(name='something', jwt_credentials=valid_credentials)


def test_get_project_id(
connector: GoogleBigQueryConnector, _fixture_credentials: GoogleCredentials
) -> None:

connector = GoogleBigQueryConnector(
name='MyGBQ',
credentials=_fixture_credentials,
jwt_credentials=JWTCredentials(jwt_token='token', project_id='123'),
scopes=[
'https://www.googleapis.com/auth/bigquery',
'https://www.googleapis.com/auth/drive',
],
)

# test get project id with jwt credentials
assert connector._get_project_id() == '123'

# test get project id with credentials
connector.jwt_credentials = None
connector.credentials = _fixture_credentials
connector.credentials.project_id = '456'
assert connector._get_project_id() == '456'

# On ProjectId missing...
with pytest.raises(GoogleClientCreationError):
connector._get_project_id()

0 comments on commit e4453a2

Please sign in to comment.