@@ -226,80 +226,80 @@ def test_endpoint_comes_from_location_service(self):
226226
227227 self .assertEqual (0 , monkey .call_count )
228228
229- # def test_location_service_miss(self):
230- # temp_client = self.temp_client("Ram", None, 'openAPI', 'ram')
231- # self.init_env(temp_client.config, "{}") # empty local config
232- #
233- # with patch.object(
234- # self._location_service_endpoint_resolver,
235- # '_call_location_service',
236- # wraps=self._location_service_endpoint_resolver._call_location_service
237- # ) as monkey:
238- #
239- # self.assertEqual(0, monkey.call_count)
240- # # No openAPI data
241- # for i in range(3):
242- # try:
243- # self.resolve("cn-hangzhou", "Ram", "ram", "openAPI")
244- # assert False
245- # except ClientException as e:
246- # self.assertEqual(error_code.SDK_ENDPOINT_RESOLVING_ERROR, e.get_error_code())
247- # self.assertTrue(e.get_error_msg().startswith(
248- # "No endpoint in the region 'cn-hangzhou' for product 'Ram'."
249- # ))
250- #
251- # self.assertEqual(1, monkey.call_count)
252- #
253- # # Bad region ID
254- # for i in range(3):
255- # try:
256- # self.resolve("mars", "Ram", "ram", "openAPI")
257- # assert False
258- # except ClientException as e:
259- # self.assertEqual(error_code.SDK_ENDPOINT_RESOLVING_ERROR, e.get_error_code())
260- # self.assertEqual(
261- # "No such region 'mars'. Please check your region ID.",
262- # e.get_error_msg()
263- # )
264- #
265- # self.assertEqual(2, monkey.call_count)
266- # # Bad region ID with another product
267- # try:
268- # self.resolve("mars", "Ecs", "ecs", "openAPI")
269- # assert False
270- # except ClientException as e:
271- # self.assertEqual(error_code.SDK_ENDPOINT_RESOLVING_ERROR, e.get_error_code())
272- # self.assertEqual("No such region 'mars'. Please check your region ID.",
273- # e.get_error_msg())
274- #
275- # self.assertEqual(2, monkey.call_count)
276- #
277- # # Bad product code
278- # for i in range(3):
279- # try:
280- # self.resolve("cn-hangzhou", "InvalidProductCode",
281- # "InvalidProductCode", "openAPI")
282- # assert False
283- # except ClientException as e:
284- # self.assertEqual(error_code.SDK_ENDPOINT_RESOLVING_ERROR, e.get_error_code())
285- # self.assertTrue(e.get_error_msg().startswith(
286- # "No endpoint for product 'InvalidProductCode'.\n"
287- # "Please check the product code, "
288- # "or set an endpoint for your request explicitly.\n"
289- # ))
290- #
291- # # Bad product code with another region ID
292- # try:
293- # self.resolve("cn-beijing", "InvalidProductCode", "InvalidProductCode", "openAPI")
294- # assert False
295- # except ClientException as e:
296- # self.assertEqual(error_code.SDK_ENDPOINT_RESOLVING_ERROR, e.get_error_code())
297- # self.assertTrue(e.get_error_msg().startswith(
298- # "No endpoint for product 'InvalidProductCode'.\n"
299- # "Please check the product code, "
300- # "or set an endpoint for your request explicitly.\n")
301- # )
302- # self.assertEqual(3, monkey.call_count)
229+ def test_location_service_miss (self ):
230+ temp_client = self .temp_client ("Ram" , None , 'openAPI' , 'ram' )
231+ self .init_env (temp_client .config , "{}" ) # empty local config
232+
233+ with patch .object (
234+ self ._location_service_endpoint_resolver ,
235+ '_call_location_service' ,
236+ wraps = self ._location_service_endpoint_resolver ._call_location_service
237+ ) as monkey :
238+
239+ self .assertEqual (0 , monkey .call_count )
240+ # No openAPI data
241+ for i in range (3 ):
242+ try :
243+ self .resolve ("cn-hangzhou" , "Ram" , "ram" , "openAPI" , temp_client . credentials_provider )
244+ assert False
245+ except ClientException as e :
246+ self .assertEqual (error_code .SDK_ENDPOINT_RESOLVING_ERROR , e .get_error_code ())
247+ self .assertTrue (e .get_error_msg ().startswith (
248+ "No endpoint in the region 'cn-hangzhou' for product 'Ram'."
249+ ))
250+
251+ self .assertEqual (1 , monkey .call_count )
252+
253+ # Bad region ID
254+ for i in range (3 ):
255+ try :
256+ self .resolve ("mars" , "Ram" , "ram" , "openAPI" , temp_client . credentials_provider )
257+ assert False
258+ except ClientException as e :
259+ self .assertEqual (error_code .SDK_ENDPOINT_RESOLVING_ERROR , e .get_error_code ())
260+ self .assertEqual (
261+ "No such region 'mars'. Please check your region ID." ,
262+ e .get_error_msg ()
263+ )
264+
265+ self .assertEqual (2 , monkey .call_count )
266+ # Bad region ID with another product
267+ try :
268+ self .resolve ("mars" , "Ecs" , "ecs" , "openAPI" , temp_client . credentials_provider )
269+ assert False
270+ except ClientException as e :
271+ self .assertEqual (error_code .SDK_ENDPOINT_RESOLVING_ERROR , e .get_error_code ())
272+ self .assertEqual ("No such region 'mars'. Please check your region ID." ,
273+ e .get_error_msg ())
274+
275+ self .assertEqual (2 , monkey .call_count )
276+
277+ # Bad product code
278+ for i in range (3 ):
279+ try :
280+ self .resolve ("cn-hangzhou" , "InvalidProductCode" ,
281+ "InvalidProductCode" , "openAPI" , temp_client . credentials_provider )
282+ assert False
283+ except ClientException as e :
284+ self .assertEqual (error_code .SDK_ENDPOINT_RESOLVING_ERROR , e .get_error_code ())
285+ self .assertTrue (e .get_error_msg ().startswith (
286+ "No endpoint for product 'InvalidProductCode'.\n "
287+ "Please check the product code, "
288+ "or set an endpoint for your request explicitly.\n "
289+ ))
290+
291+ # Bad product code with another region ID
292+ try :
293+ self .resolve ("cn-beijing" , "InvalidProductCode" , "InvalidProductCode" , "openAPI" , temp_client . credentials_provider )
294+ assert False
295+ except ClientException as e :
296+ self .assertEqual (error_code .SDK_ENDPOINT_RESOLVING_ERROR , e .get_error_code ())
297+ self .assertTrue (e .get_error_msg ().startswith (
298+ "No endpoint for product 'InvalidProductCode'.\n "
299+ "Please check the product code, "
300+ "or set an endpoint for your request explicitly.\n " )
301+ )
302+ self .assertEqual (3 , monkey .call_count )
303303
304304 def test_try_to_get_endpoint_with_invalid_region_id (self ):
305305 temp_client = self .temp_client ('ecs' )
0 commit comments