def test_handle_http_exception(self):
        func = MagicMock()
        wrapped = handle_http_exception(func)

        func.return_value = 42
        self.assertEqual(wrapped(40, 2, operation='add'), 42)
        func.assert_called_once_with(40, 2, operation='add')

        func.side_effect = SlumberHttpBaseException(content='error message')
        with six.assertRaisesRegex(self, ResolweServerError, 'error message'):
            wrapped()
def _mock_session_send(*args, **kwargs):
    raise SlumberHttpBaseException(
        content=json.dumps({"eligibility_check": ["Case with this Eligibility check already exists."]})
    )
Example #3
0
 def setUp(self):
     self.resource = ResolweResource()
     self.method_mock = MagicMock(
         side_effect=[42,
                      SlumberHttpBaseException(content='error mesage')])