diff --git a/tests/google_big_query/test_google_big_query.py b/tests/google_big_query/test_google_big_query.py index 64851b99d..7289038a5 100644 --- a/tests/google_big_query/test_google_big_query.py +++ b/tests/google_big_query/test_google_big_query.py @@ -852,3 +852,21 @@ 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: + # test get project id with jwt credentials + connector.jwt_credentials = JWTCredentials(jwt_token='token', project_id='123') + 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()