Example #1
0
    def test_request_with_general_exception(self):
        hook = enas_utils.RequestSideEffect()
        hook.append(ex=url_error.HTTPError(XML_CONN_TD.req_url(), 'error_code',
                                           'fake_message', None, None))
        self.XmlConnector.url_opener.open = mock.Mock(side_effect=hook)

        self.assertRaises(exception.ManilaException, self.XmlConnector.request,
                          XML_CONN_TD.FAKE_BODY)
Example #2
0
    def test_request_with_no_authorized_exception(self):
        xml_socket = mock.Mock()
        xml_socket.read = mock.Mock(return_value=XML_CONN_TD.FAKE_RESP)

        hook = enas_utils.RequestSideEffect()
        hook.append(ex=url_error.HTTPError(XML_CONN_TD.req_url(), '403',
                                           'fake_message', None, None))
        hook.append(xml_socket)
        hook.append(xml_socket)

        self.XmlConnector.url_opener.open = mock.Mock(side_effect=hook)

        self.XmlConnector.request(XML_CONN_TD.FAKE_BODY)