示例#1
0
 def test_annonymous_client(self):
     env = EnvironmentVarGuard()
     env.set('KAGGLE_USER_SECRETS_TOKEN', 'foobar')
     env.set('KAGGLE_KERNEL_INTEGRATIONS', 'GCS')
     with env:
         init_gcs()
         anonymous = storage.Client.create_anonymous_client()
         self.assertIsNotNone(anonymous)
示例#2
0
 def test_default_credentials_gcs_enabled(self):
     env = EnvironmentVarGuard()
     env.set('KAGGLE_USER_SECRETS_TOKEN', 'foobar')
     env.set('KAGGLE_KERNEL_INTEGRATIONS', 'GCS')
     with env:
         init_gcs()
         client = storage.Client(project="xyz")
         self.assertIsInstance(client._credentials, KaggleKernelCredentials)
示例#3
0
 def test_monkeypatching_idempotent(self):
     env = EnvironmentVarGuard()
     env.set('KAGGLE_USER_SECRETS_TOKEN', 'foobar')
     env.set('KAGGLE_KERNEL_INTEGRATIONS', 'GCS')
     with env:
         client1 = storage.Client.__init__
         init_gcs()
         client2 = storage.Client.__init__
         self.assertEqual(client1, client2)
示例#4
0
 def test_ctr(self):
     credentials = _make_credentials()
     env = EnvironmentVarGuard()
     env.set('KAGGLE_USER_SECRETS_TOKEN', 'foobar')
     env.set('KAGGLE_KERNEL_INTEGRATIONS', 'GCS')
     with env:
         init_gcs()
         client = storage.Client(project="xyz", credentials=credentials)
         self.assertEqual(client.project, "xyz")
         self.assertNotIsInstance(client._credentials,
                                  KaggleKernelCredentials)
         self.assertIsNotNone(client._credentials)