def test_error_code_map(self):
     for code, exception in six.iteritems(error_code_map):
         self._failure_method.side_effect = LaunchKeyAPIException(
             {
                 "error_code": code,
                 "error_detail": ANY
             }, 400)
         with self.assertRaises(exception):
             api_call(self._failure_method)()
예제 #2
0
 def test_error_code_map_without_error_data(self):
     for code, exception in six.iteritems(ERROR_CODE_MAP):
         self._failure_method.side_effect = LaunchKeyAPIException(
             {
                 "error_code": code,
                 "error_detail": {
                     "error": "details"
                 }
             }, 400)
         with self.assertRaises(exception) as raised:
             api_call(self._failure_method)()
         self.assertEqual(raised.exception.data, {})
예제 #3
0
 def test_error_code_map_message_passthrough(self):
     for code, exception in six.iteritems(ERROR_CODE_MAP):
         self._failure_method.side_effect = LaunchKeyAPIException(
             {
                 "error_code": code,
                 "error_detail": {
                     "error": "details"
                 }
             }, 400)
         with self.assertRaises(exception) as raised:
             api_call(self._failure_method)()
         self.assertEqual(raised.exception.message, {"error": "details"})
         self.assertEqual(raised.exception.status_code, 400)
         self.assertIsNone(raised.exception.reason)
 def test_unexpected_error(self):
     self._failure_method.side_effect = LaunchKeyAPIException()
     with self.assertRaises(LaunchKeyAPIException):
         api_call(self._failure_method)()
 def test_status_code_map(self):
     for code, exception in six.iteritems(status_code_map):
         self._failure_method.side_effect = LaunchKeyAPIException({}, code)
         with self.assertRaises(exception):
             api_call(self._failure_method)()
 def test_success(self):
     method = MagicMock()
     method.__name__ = str(uuid4())
     self.assertEqual(api_call(method)(), method())