def test_monkeypatching_succeed(self):
     env = EnvironmentVarGuard()
     env.set('KAGGLE_USER_SECRETS_TOKEN', 'foobar')
     env.set('KAGGLE_KERNEL_INTEGRATIONS', 'TRANSLATION')
     with env:
         init_video_intelligence()
         client = videointelligence.VideoIntelligenceServiceClient.__init__
         self.assertTrue("kaggle_gcp" in inspect.getsourcefile(client))
 def test_default_credentials(self):
     env = EnvironmentVarGuard()
     env.set('KAGGLE_USER_SECRETS_TOKEN', 'foobar')
     env.set('KAGGLE_KERNEL_INTEGRATIONS', 'VIDEO_INTELLIGENCE')
     with env:
         init_video_intelligence()
         client = videointelligence.VideoIntelligenceServiceClient()
         self.assertIsNotNone(client.credentials)
         self.assertIsInstance(client.credentials, KaggleKernelCredentials)
 def test_monkeypatching_idempotent(self):
     env = EnvironmentVarGuard()
     env.set('KAGGLE_USER_SECRETS_TOKEN', 'foobar')
     env.set('KAGGLE_KERNEL_INTEGRATIONS', 'VIDEO_INTELLIGENCE')
     with env:
         init_video_intelligence()
         client1 = videointelligence.VideoIntelligenceServiceClient.__init__
         init_video_intelligence()
         client2 = videointelligence.VideoIntelligenceServiceClient.__init__
         self.assertEqual(client1, client2)
Exemplo n.º 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', 'CLOUDAI')
     with env:
         init_video_intelligence()
         client = videointelligence.VideoIntelligenceServiceClient(credentials=credentials)
         self.assertNotIsInstance(client.credentials, KaggleKernelCredentials)
         self.assertIsNotNone(client.credentials)