FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
docker-python/tests/test_gcs.py at master · HpcDataLab/docker-python · GitHub
HpcDataLab
/
docker-python
Public
forked from
Kaggle/docker-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
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_gcs.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
57 lines (48 loc) · 2.06 KB
Breadcrumbs
docker-python
/
tests
/
test_gcs.py
Copy path
File metadata and controls
57 lines (48 loc) · 2.06 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import
unittest
from
unittest
.
mock
import
Mock
from
kaggle_gcp
import
KaggleKernelCredentials
,
init_gcs
from
test
.
support
import
EnvironmentVarGuard
from
google
.
cloud
import
storage
def
_make_credentials
():
import
google
.
auth
.
credentials
return
Mock
(
spec
=
google
.
auth
.
credentials
.
Credentials
)
class
TestStorage
(
unittest
.
TestCase
):
def
test_version
(
self
):
self
.
assertIsNotNone
(
storage
.
__version__
)
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
)
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
)
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
)
self
.
assertTrue
(
client
.
_connection
.
user_agent
.
startswith
(
"kaggle-gcp-client/1.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
)
Back
|
FazBrowse Home
|
New Git URL