Beispiel #1
0
    def test_get_api_error(self):
        method = 'GET'
        action = 'DescribeLoadBalancers'
        params = dict()

        with mock.patch('requests.get', self.mockRequestsInternalServerError):
            info = nifcloud_lb.request_to_api(self.mockModule, method,
                                              action, params)

        error_info = nifcloud_lb.get_api_error(info['xml_body'])
        self.assertEqual(error_info['code'],    'Server.InternalError')
        self.assertEqual(error_info['message'],
                         'An error has occurred. Please try again later.')
Beispiel #2
0
    def test_request_to_api_error(self):
        method = 'GET'
        action = 'DescribeLoadBalancers'
        params = dict()

        with mock.patch('requests.get', self.mockRequestsInternalServerError):
            info = nifcloud_lb.request_to_api(self.mockModule, method, action,
                                              params)

        self.assertEqual(info['status'], 500)
        self.assertEqual(
            etree.tostring(info['xml_body']),
            etree.tostring(etree.fromstring(self.xml['internalServerError'])))
Beispiel #3
0
    def test_request_to_api_get(self):
        method = 'GET'
        action = 'DescribeLoadBalancers'
        params = dict()

        with mock.patch('requests.get',
                        self.mockRequestsGetDescribeLoadBalancers):
            info = nifcloud_lb.request_to_api(self.mockModule, method,
                                              action, params)

        self.assertEqual(info['status'], 200)
        self.assertEqual(info['xml_namespace'], dict(nc=self.xmlnamespace))
        self.assertEqual(
            etree.tostring(info['xml_body']),
            etree.tostring(etree.fromstring(self.xml['describeLoadBalancers']))
        )