コード例 #1
0
ファイル: aws_http.py プロジェクト: rcosnita/aws-tests
 def setUp(self):
     AwsExceptionsFactory._EX_REGISTRY.clear()
     
     AwsExceptionsFactory.add_exception("TestEx", TestEx)
     
     self._http_cls = Mock()
     self._http_module = Mock(return_value=self._http_cls)
     self._http_client = AwsHttpClient(self._http_module)
コード例 #2
0
 def test_add_exception(self):
     '''Test case for add_exception method success scenario.'''
     
     AwsExceptionsFactory.add_exception("AccessDenied", TestEx)
     
     result = AwsExceptionsFactory._EX_REGISTRY.get("AccessDenied")
     
     self.assertIsNotNone(result)
     self.assertIs(TestEx, result)
コード例 #3
0
 def test_get_exception_concrete(self):
     '''Test case for get exception method when a concrete exception is found.'''
     
     AwsExceptionsFactory.add_exception("AccessDenied", TestEx)
     
     for code in ["AccessDenied", "Access.Denied"]:
         self._error_response["ErrorResponse"]["Error"]["Code"] = code
         ex = AwsExceptionsFactory.get_exception(self._error_response)
         
         self.assertIsInstance(ex, TestEx)
         self.assertEqual(400, ex.http_status)
         self.assertEqual("Sender", ex.error_type)
         self.assertEqual("AccessDenied", ex.error_code)
         self.assertEqual("Test message", ex.error_msg)
         self.assertEqual("123", ex.request_id)
コード例 #4
0
 def test_add_exception_exist(self):
     '''Test case for add_exception method when the code is already registered in the factory.'''
     
     AwsExceptionsFactory.add_exception("AccessDenied", TestEx)
     
     self.assertRaises(ValueError, AwsExceptionsFactory.add_exception, *["AccessDenied", TestEx])