File tree 3 files changed +44
-0
lines changed 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ client_config_backend : service
2
+ service_config :
3
+ client_json_file_path : /tmp/pydrive2/credentials.json
4
+
5
+ save_credentials : False
6
+
7
+ oauth_scope :
8
+ - https://www.googleapis.com/auth/drive
Original file line number Diff line number Diff line change
1
+ client_config_backend : service
2
+ service_config :
3
+ client_json_file_path : /tmp/pydrive2/credentials.json
4
+
5
+ save_credentials : True
6
+ save_credentials_backend : file
7
+ save_credentials_file : credentials/9.dat
8
+
9
+ oauth_scope :
10
+ - https://www.googleapis.com/auth/drive
Original file line number Diff line number Diff line change 8
8
delete_file ,
9
9
settings_file_path ,
10
10
)
11
+ from oauth2client .file import Storage
11
12
12
13
13
14
def setup_module (module ):
@@ -99,6 +100,31 @@ def test_07_ServiceAuthFromSavedCredentialsJsonFile():
99
100
time .sleep (1 )
100
101
101
102
103
+ def test_08_ServiceAuthFromJsonFileNoCredentialsSaving ():
104
+ # Test that no credentials are saved and API is still functional
105
+ # We are testing that there are no exceptions at least
106
+ ga = GoogleAuth (settings_file_path ("test_oauth_test_08.yaml" ))
107
+ assert not ga .settings ["save_credentials" ]
108
+ ga .ServiceAuth ()
109
+ time .sleep (1 )
110
+
111
+
112
+ def test_09_SaveLoadCredentialsUsesDefaultStorage (mocker ):
113
+ # Test fix for https://github.com/iterative/PyDrive2/issues/163
114
+ # Make sure that Load and Save credentials by default reuse the
115
+ # same Storage (since it defined lock which make it TS)
116
+ ga = GoogleAuth (settings_file_path ("test_oauth_test_09.yaml" ))
117
+ credentials_file = ga .settings ["save_credentials_file" ]
118
+ # Delete old credentials file
119
+ delete_file (credentials_file )
120
+ assert not os .path .exists (credentials_file )
121
+ spy = mocker .spy (Storage , "__init__" )
122
+ ga .ServiceAuth ()
123
+ ga .LoadCredentials ()
124
+ ga .SaveCredentials ()
125
+ assert spy .call_count == 0
126
+
127
+
102
128
def CheckCredentialsFile (credentials , no_file = False ):
103
129
ga = GoogleAuth (settings_file_path ("test_oauth_default.yaml" ))
104
130
ga .LoadCredentialsFile (credentials )
You can’t perform that action at this time.
0 commit comments