def test_magics_without_connected_account(self): env = EnvironmentVarGuard() env.set('KAGGLE_USER_SECRETS_TOKEN', 'foobar') with env: import sitecustomize sitecustomize.init() from google.cloud.bigquery import magics self.assertIsNone(magics.context._credentials)
def test_default_credentials_gcs_enabled(self): env = EnvironmentVarGuard() env.set('KAGGLE_USER_SECRETS_TOKEN', 'foobar') env.set('KAGGLE_KERNEL_INTEGRATIONS', 'GCS') with env: from sitecustomize import init init() client = storage.Client(project="xyz") self.assertIsInstance(client._credentials, KaggleKernelCredentials)
def test_magics_with_connected_account_default_credentials(self): env = EnvironmentVarGuard() env.set('KAGGLE_USER_SECRETS_TOKEN', 'foobar') env.set('KAGGLE_KERNEL_INTEGRATIONS', 'BIGQUERY') with env: import sitecustomize sitecustomize.init() from google.cloud.bigquery import magics self.assertEqual(type(magics.context._credentials), KaggleKernelCredentials) magics.context.credentials = None