MaximCherchuk

tests

Oct 30th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. def get_coroutine_mock():
  2.     coro = Mock(name="corutine_result")
  3.     coroutine_function = Mock(
  4.         name="coroutine_function",
  5.         side_effect=coroutine(coro),
  6.     )
  7.     coroutine_function.coro = coro
  8.     return coroutine_function
  9.  
  10.  
  11. class TestCognitoAuthDomainServiceCreateCustomer(TestCase):
  12.     @patch(
  13.         'cognito.library.identity.AsyncCognito.register',
  14.         new_callable=get_coroutine_mock,
  15.     )
  16.     def test_create_customer__too_many_requests_exception(self, register_mock):
  17.  
  18.         register_mock.coro.side_effect = Mock(
  19.             side_effect=TooManyRequestsException()
  20.         )
  21.  
  22.         with self.assertRaises(exceptions.BackendAtCapacityException):
  23.             self._run_helper(
  24.                 self.cognito_auth_domain_service.create_customer,
  25.                 self.customer,
  26.                 self.password,
  27.             )
Advertisement
Add Comment
Please, Sign In to add comment