def test_api_call_throttle_should_pass(self): request = FakeApi().create_request() request.is_response_valid = MagicMock(return_value=True) request.requests_per_seconds = 5 for i in range(request.requests_per_seconds): request.call()
def test_api_call_throttle_should_fail(self): request = FakeApi().create_request() request.is_response_valid = MagicMock(return_value=True) request.requests_per_seconds = 5 with self.assertRaises(TimeoutError): for i in range(request.requests_per_seconds * 2): request.call()
def test_mocked_call(self): request = FakeApi().create_request(True) request.is_response_valid = MagicMock(return_value=True) request.get_inventory(test='awesome') result = request.call() self.assertTrue(result)