14
14
15
15
import unittest
16
16
17
+ from google .cloud .storage import _helpers
18
+
17
19
import mock
18
20
19
21
@@ -112,7 +114,7 @@ def test_w_generation(self):
112
114
self .assertTrue (self ._call_fut (query_params ))
113
115
114
116
def test_wo_generation_w_if_generation_match (self ):
115
- query_params = {"if_generation_match " : 123 }
117
+ query_params = {"ifGenerationMatch " : 123 }
116
118
117
119
self .assertTrue (self ._call_fut (query_params ))
118
120
@@ -129,7 +131,7 @@ def test_w_empty(self):
129
131
self .assertFalse (self ._call_fut (query_params ))
130
132
131
133
def test_w_if_metageneration_match (self ):
132
- query_params = {"if_metageneration_match " : 123 }
134
+ query_params = {"ifMetagenerationMatch " : 123 }
133
135
134
136
self .assertTrue (self ._call_fut (query_params ))
135
137
@@ -163,48 +165,62 @@ def test_w_empty_data(self):
163
165
164
166
165
167
class Test_default_conditional_retry_policies (unittest .TestCase ):
166
- def test_is_generation_specified_match_metageneration (self ):
168
+ def test_is_generation_specified_match_generation_match (self ):
167
169
from google .cloud .storage import retry
168
170
171
+ query_dict = {}
172
+ _helpers ._add_generation_match_parameters (query_dict , if_generation_match = 1 )
173
+
169
174
conditional_policy = retry .DEFAULT_RETRY_IF_GENERATION_SPECIFIED
170
175
policy = conditional_policy .get_retry_policy_if_conditions_met (
171
- query_params = { "if_generation_match" : 1 }
176
+ query_params = query_dict
172
177
)
173
178
self .assertEqual (policy , retry .DEFAULT_RETRY )
174
179
175
180
def test_is_generation_specified_match_generation (self ):
176
181
from google .cloud .storage import retry
177
182
183
+ query_dict = {"generation" : 1 }
184
+
178
185
conditional_policy = retry .DEFAULT_RETRY_IF_GENERATION_SPECIFIED
179
186
policy = conditional_policy .get_retry_policy_if_conditions_met (
180
- query_params = { "generation" : 1 }
187
+ query_params = query_dict
181
188
)
182
189
self .assertEqual (policy , retry .DEFAULT_RETRY )
183
190
184
191
def test_is_generation_specified_mismatch (self ):
185
192
from google .cloud .storage import retry
186
193
194
+ query_dict = {}
195
+ _helpers ._add_generation_match_parameters (query_dict , if_metageneration_match = 1 )
196
+
187
197
conditional_policy = retry .DEFAULT_RETRY_IF_GENERATION_SPECIFIED
188
198
policy = conditional_policy .get_retry_policy_if_conditions_met (
189
- query_params = { "if_metageneration_match" : 1 }
199
+ query_params = query_dict
190
200
)
191
201
self .assertEqual (policy , None )
192
202
193
203
def test_is_metageneration_specified_match (self ):
194
204
from google .cloud .storage import retry
195
205
206
+ query_dict = {}
207
+ _helpers ._add_generation_match_parameters (query_dict , if_metageneration_match = 1 )
208
+
196
209
conditional_policy = retry .DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED
197
210
policy = conditional_policy .get_retry_policy_if_conditions_met (
198
- query_params = { "if_metageneration_match" : 1 }
211
+ query_params = query_dict
199
212
)
200
213
self .assertEqual (policy , retry .DEFAULT_RETRY )
201
214
202
215
def test_is_metageneration_specified_mismatch (self ):
203
216
from google .cloud .storage import retry
204
217
218
+ query_dict = {}
219
+ _helpers ._add_generation_match_parameters (query_dict , if_generation_match = 1 )
220
+
205
221
conditional_policy = retry .DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED
206
222
policy = conditional_policy .get_retry_policy_if_conditions_met (
207
- query_params = { "if_generation_match" : 1 }
223
+ query_params = query_dict
208
224
)
209
225
self .assertEqual (policy , None )
210
226
@@ -213,7 +229,7 @@ def test_is_etag_in_json_etag_match(self):
213
229
214
230
conditional_policy = retry .DEFAULT_RETRY_IF_ETAG_IN_JSON
215
231
policy = conditional_policy .get_retry_policy_if_conditions_met (
216
- query_params = {"if_generation_match " : 1 }, data = '{"etag": "12345678"}'
232
+ query_params = {"ifGenerationMatch " : 1 }, data = '{"etag": "12345678"}'
217
233
)
218
234
self .assertEqual (policy , retry .DEFAULT_RETRY )
219
235
@@ -222,7 +238,7 @@ def test_is_etag_in_json_mismatch(self):
222
238
223
239
conditional_policy = retry .DEFAULT_RETRY_IF_ETAG_IN_JSON
224
240
policy = conditional_policy .get_retry_policy_if_conditions_met (
225
- query_params = {"if_generation_match " : 1 }, data = "{}"
241
+ query_params = {"ifGenerationMatch " : 1 }, data = "{}"
226
242
)
227
243
self .assertEqual (policy , None )
228
244
@@ -231,6 +247,6 @@ def test_is_meta_or_etag_in_json_invalid(self):
231
247
232
248
conditional_policy = retry .DEFAULT_RETRY_IF_ETAG_IN_JSON
233
249
policy = conditional_policy .get_retry_policy_if_conditions_met (
234
- query_params = {"if_generation_match " : 1 }, data = "I am invalid JSON!"
250
+ query_params = {"ifGenerationMatch " : 1 }, data = "I am invalid JSON!"
235
251
)
236
252
self .assertEqual (policy , None )
0 commit comments