def test_fail_requestV3(self): status_code = '404' fail_send = mock.Mock(return_value=status_code) with mock.patch.object(client, 'send_request', fail_send): from mock_exp import get_result self.assertEqual(get_result(), status_code)
def test_success_requestV2(self): status_code = '200' success_send = mock.Mock(return_value=status_code) with mock.patch('mock_exp.send_request', success_send): from mock_exp import get_result self.assertEqual(get_result(), status_code)
def test_fail_request(self): fail_send = mock.Mock(return_value='404') client.send_request = fail_send self.assertEqual(client.get_result(), '404')
def test_call_send_request_with_right_arguments(self): client.send_request = mock.Mock() client.get_result() self.assertEqual(client.send_request.called, True) call_args = client.send_request.call_args self.assertIsInstance(call_args[0][0], str)
def test_success_request(self): success_send = mock.Mock(return_value='200') client.send_request = success_send self.assertEqual(client.get_result(), '200')