Exemplo n.º 1
0
    def test_run_error_callback(self):
        mock_error_cb = Mock()

        req = Request('http://dummy', error_callback=mock_error_cb)

        mock_resp = ErrorResponse(req, Exception())
        req.run_callback(mock_resp)

        mock_error_cb.assert_called_once_with(mock_resp)
Exemplo n.º 2
0
    def test_run_success_callback(self):
        mock_success_cb = Mock()

        req = Request('http://dummy', success_callback=mock_success_cb)

        mock_resp = Response(req, 200, 'content', {})
        req.run_callback(mock_resp)

        mock_success_cb.assert_called_once_with(mock_resp)
Exemplo n.º 3
0
 def test_run_callback_with_invalid_response(self):
     req = Request('http://dummy')
     req.run_callback({})