FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
docker-python/tests/test_tensorflow_credentials.py at master · AI-For-Rural/docker-python · GitHub
AI-For-Rural
/
docker-python
Public
forked from
Kaggle/docker-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
docker-python
/
tests
/
test_tensorflow_credentials.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (29 loc) · 1.33 KB
Breadcrumbs
docker-python
/
tests
/
test_tensorflow_credentials.py
Copy path
File metadata and controls
37 lines (29 loc) · 1.33 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import
unittest
import
os
import
tensorflow_gcs_config
from
unittest
.
mock
import
patch
from
test
.
support
import
EnvironmentVarGuard
from
kaggle_secrets
import
UserSecretsClient
class
TestTensorflowCredentials
(
unittest
.
TestCase
):
@
patch
(
'tensorflow_gcs_config.configure_gcs'
)
def
test_set_tensorflow_credential
(
self
,
mock_configure_gcs
):
credential
=
'{"client_id":"fake_client_id",'
\
'"client_secret":"fake_client_secret",'
\
'"refresh_token":"not a refresh token",'
\
'"type":"authorized_user"}'
;
env
=
EnvironmentVarGuard
()
env
.
set
(
'HOME'
,
'/tmp'
)
env
.
set
(
'GOOGLE_APPLICATION_CREDENTIALS'
,
''
)
# These need to be set to make UserSecretsClient happy, but aren't
# pertinent to this test.
env
.
set
(
'KAGGLE_USER_SECRETS_TOKEN'
,
'foobar'
)
env
.
set
(
'KAGGLE_KERNEL_INTEGRATIONS'
,
'AUTOML'
)
user_secrets
=
UserSecretsClient
()
user_secrets
.
set_tensorflow_credential
(
credential
)
credential_path
=
'/tmp/gcloud_credential.json'
self
.
assertEqual
(
credential_path
,
os
.
environ
[
'GOOGLE_APPLICATION_CREDENTIALS'
])
with
open
(
credential_path
,
'r'
)
as
f
:
saved_cred
=
f
.
read
()
self
.
assertEqual
(
credential
,
saved_cred
)
mock_configure_gcs
.
assert_called_with
(
credentials
=
credential
)
Back
|
FazBrowse Home
|
New Git URL