Пример #1
0
 def test_monkeypatching_succeed(self):
     env = EnvironmentVarGuard()
     env.set('KAGGLE_USER_SECRETS_TOKEN', 'foobar')
     env.set('KAGGLE_KERNEL_INTEGRATIONS', 'CLOUDAI')
     with env:
         init_vision()
         client = vision.ImageAnnotatorClient.__init__
         self.assertTrue("kaggle_gcp" in inspect.getsourcefile(client))
Пример #2
0
 def test_default_credentials(self):
     env = EnvironmentVarGuard()
     env.set('KAGGLE_USER_SECRETS_TOKEN', 'foobar')
     env.set('KAGGLE_KERNEL_INTEGRATIONS', 'CLOUDAI')
     with env:
         init_vision()
         client = vision.ImageAnnotatorClient()
         self.assertIsNotNone(client.credentials)
         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', 'CLOUDAI')
     with env:
         init_vision()
         client1 = vision.ImageAnnotatorClient.__init__
         init_vision()
         client2 = vision.ImageAnnotatorClient.__init__
         self.assertEqual(client1, client2)
Пример #4
0
 def test_user_provided_credentials(self):
     credentials = _make_credentials()
     env = EnvironmentVarGuard()
     env.set('KAGGLE_USER_SECRETS_TOKEN', 'foobar')
     env.set('KAGGLE_KERNEL_INTEGRATIONS', 'VISION')
     with env:
         init_vision()
         client = vision.ImageAnnotatorClient(credentials=credentials)
         self.assertNotIsInstance(client.credentials,
                                  KaggleKernelCredentials)
         self.assertIsNotNone(client.credentials)