1414
1515import unittest
1616
17+ from google .cloud .storage import _helpers
18+
1719import mock
1820
1921
@@ -112,7 +114,7 @@ def test_w_generation(self):
112114 self .assertTrue (self ._call_fut (query_params ))
113115
114116 def test_wo_generation_w_if_generation_match (self ):
115- query_params = {"if_generation_match " : 123 }
117+ query_params = {"ifGenerationMatch " : 123 }
116118
117119 self .assertTrue (self ._call_fut (query_params ))
118120
@@ -129,7 +131,7 @@ def test_w_empty(self):
129131 self .assertFalse (self ._call_fut (query_params ))
130132
131133 def test_w_if_metageneration_match (self ):
132- query_params = {"if_metageneration_match " : 123 }
134+ query_params = {"ifMetagenerationMatch " : 123 }
133135
134136 self .assertTrue (self ._call_fut (query_params ))
135137
@@ -163,48 +165,62 @@ def test_w_empty_data(self):
163165
164166
165167class 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 ):
167169 from google .cloud .storage import retry
168170
171+ query_dict = {}
172+ _helpers ._add_generation_match_parameters (query_dict , if_generation_match = 1 )
173+
169174 conditional_policy = retry .DEFAULT_RETRY_IF_GENERATION_SPECIFIED
170175 policy = conditional_policy .get_retry_policy_if_conditions_met (
171- query_params = { "if_generation_match" : 1 }
176+ query_params = query_dict
172177 )
173178 self .assertEqual (policy , retry .DEFAULT_RETRY )
174179
175180 def test_is_generation_specified_match_generation (self ):
176181 from google .cloud .storage import retry
177182
183+ query_dict = {"generation" : 1 }
184+
178185 conditional_policy = retry .DEFAULT_RETRY_IF_GENERATION_SPECIFIED
179186 policy = conditional_policy .get_retry_policy_if_conditions_met (
180- query_params = { "generation" : 1 }
187+ query_params = query_dict
181188 )
182189 self .assertEqual (policy , retry .DEFAULT_RETRY )
183190
184191 def test_is_generation_specified_mismatch (self ):
185192 from google .cloud .storage import retry
186193
194+ query_dict = {}
195+ _helpers ._add_generation_match_parameters (query_dict , if_metageneration_match = 1 )
196+
187197 conditional_policy = retry .DEFAULT_RETRY_IF_GENERATION_SPECIFIED
188198 policy = conditional_policy .get_retry_policy_if_conditions_met (
189- query_params = { "if_metageneration_match" : 1 }
199+ query_params = query_dict
190200 )
191201 self .assertEqual (policy , None )
192202
193203 def test_is_metageneration_specified_match (self ):
194204 from google .cloud .storage import retry
195205
206+ query_dict = {}
207+ _helpers ._add_generation_match_parameters (query_dict , if_metageneration_match = 1 )
208+
196209 conditional_policy = retry .DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED
197210 policy = conditional_policy .get_retry_policy_if_conditions_met (
198- query_params = { "if_metageneration_match" : 1 }
211+ query_params = query_dict
199212 )
200213 self .assertEqual (policy , retry .DEFAULT_RETRY )
201214
202215 def test_is_metageneration_specified_mismatch (self ):
203216 from google .cloud .storage import retry
204217
218+ query_dict = {}
219+ _helpers ._add_generation_match_parameters (query_dict , if_generation_match = 1 )
220+
205221 conditional_policy = retry .DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED
206222 policy = conditional_policy .get_retry_policy_if_conditions_met (
207- query_params = { "if_generation_match" : 1 }
223+ query_params = query_dict
208224 )
209225 self .assertEqual (policy , None )
210226
@@ -213,7 +229,7 @@ def test_is_etag_in_json_etag_match(self):
213229
214230 conditional_policy = retry .DEFAULT_RETRY_IF_ETAG_IN_JSON
215231 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"}'
217233 )
218234 self .assertEqual (policy , retry .DEFAULT_RETRY )
219235
@@ -222,7 +238,7 @@ def test_is_etag_in_json_mismatch(self):
222238
223239 conditional_policy = retry .DEFAULT_RETRY_IF_ETAG_IN_JSON
224240 policy = conditional_policy .get_retry_policy_if_conditions_met (
225- query_params = {"if_generation_match " : 1 }, data = "{}"
241+ query_params = {"ifGenerationMatch " : 1 }, data = "{}"
226242 )
227243 self .assertEqual (policy , None )
228244
@@ -231,6 +247,6 @@ def test_is_meta_or_etag_in_json_invalid(self):
231247
232248 conditional_policy = retry .DEFAULT_RETRY_IF_ETAG_IN_JSON
233249 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!"
235251 )
236252 self .assertEqual (policy , None )
0 commit comments