forked from Kaggle/docker-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_ucaip.py
24 lines (19 loc) · 884 Bytes
/
test_ucaip.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import unittest
from unittest.mock import Mock
from kaggle_gcp import KaggleKernelCredentials, init_ucaip
from test.support import EnvironmentVarGuard
def _make_credentials():
import google.auth.credentials
return Mock(spec=google.auth.credentials.Credentials)
class TestUcaip(unittest.TestCase):
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:
from google.cloud import aiplatform
init_ucaip()
aiplatform.init(credentials=credentials)
self.assertNotIsInstance(aiplatform.initializer.global_config.credentials, KaggleKernelCredentials)
self.assertIsNotNone(aiplatform.initializer.global_config.credentials)