def test_json_content_type(self):
     client = AcsClient("id", "aks", region_id='cn-hangzhou', port=51352)
     request = RpcRequest('sts', '2020', 'test')
     request.endpoint = 'localhost'
     request.set_method('POST')
     request.set_content_type('application/json')
     request.add_body_params('key', 'value')
     response = self.do_request(client, request)
     if sys.version_info.major == 2:
         headers = {
             item.split(':')[0]: item.split(':')[1]
             for item in response.headers.headers
         }
     else:
         headers = dict(response.headers._headers)
     self.assertEqual('application/json',
                      headers['Content-Type'].strip('\r\n '))
    def test_resolve_endpoint(self):
        client = AcsClient("id", "aks", region_id='', port=51352)
        req = RpcRequest('sts', '2020', 'test')
        req.endpoint = 'localhost'
        req.request_network = ''
        req.product_suffix = ''
        self.do_request(client, req)

        try:
            client._resolve_endpoint(req)
        except Exception as e:
            self.assertEqual("No such region ''. Please check your region ID.",
                             e.message)

        client.set_region_id('cn@hangzhou')
        try:
            client._resolve_endpoint(req)
        except Exception as e:
            self.assertEqual(
                'The parameter region_id not match with ^[a-zA-Z0-9_-]+$',
                e.message)