Ejemplo n.º 1
0
    def test_request_exception(self):
        request = self.soap_client.request
        request.side_effect = Exception

        requestor = SoapRequestor(self.soap_client)
        with self.assertRaises(Exception):
            requestor.request('methodName', 'arg', kw='kw')
    def test_request_exception(self):
        request = self.soap_client.request
        request.side_effect = Exception

        requestor = SoapRequestor(self.soap_client)
        with self.assertRaises(Exception):
            requestor.request("methodName", "arg", kw="kw")
Ejemplo n.º 3
0
    def test_request_server_exception(self):
        request = self.soap_client.request
        request.side_effect = SoapServerException('code', 123)

        requestor = SoapRequestor(self.soap_client)
        with self.assertRaises(SoapServerException) as ctx:
            requestor.request('methodName', 'arg', kw='kw')
        self.assertEqual(123, ctx.exception.code)
        self.assertEqual('code', ctx.exception.error)
    def test_request_server_exception(self):
        request = self.soap_client.request
        request.side_effect = SoapServerException("code", 123,
                                                  mock.Mock(spec=SoapRequest))

        requestor = SoapRequestor(self.soap_client)
        with self.assertRaises(SoapServerException) as ctx:
            requestor.request("methodName", "arg", kw="kw")
        self.assertEqual(123, ctx.exception.code)
        self.assertEqual("code", ctx.exception.error)
    def test_request(self):
        request = self.soap_client.request
        mocked_result = mock.Mock()
        mocked_envelope_sent = mock.Mock()
        mocked_envelope_received = mock.Mock()
        request.return_value = (
            mocked_result,
            mocked_envelope_sent,
            mocked_envelope_received,
        )
        args = ("arg", )
        kwargs = {"kw": "kw"}
        expected_request = SoapRequest(method_name="methodName",
                                       args=args,
                                       kwargs=kwargs)
        expected_response = SoapResponse(
            request=expected_request,
            result=mocked_result,
            envelope_sent=mocked_envelope_sent,
            envelope_received=mocked_envelope_received,
        )

        requestor = SoapRequestor(self.soap_client)
        response = requestor.request("methodName", *args, **kwargs)

        self.assertEqual(expected_response, response)
Ejemplo n.º 6
0
    def test_request(self):
        request = self.soap_client.request
        mocked_result = mock.Mock()
        mocked_envelope_sent = mock.Mock()
        mocked_envelope_received = mock.Mock()
        request.return_value = (mocked_result, mocked_envelope_sent,
                                mocked_envelope_received)
        args = ('arg', )
        kwargs = {'kw': 'kw'}
        expected_request = SoapRequest(method_name='methodName',
                                       args=args,
                                       kwargs=kwargs)
        expected_response = SoapResponse(
            request=expected_request,
            result=mocked_result,
            envelope_sent=mocked_envelope_sent,
            envelope_received=mocked_envelope_received)

        requestor = SoapRequestor(self.soap_client)
        response = requestor.request('methodName', *args, **kwargs)

        self.assertEqual(expected_response, response)