Пример #1
0
    def test_to_xml_success_with_data(self):
        params = {
            'data': {'Field1': 'Test field'},
            'root': 'OuterField',
        }
        result = to_xml(**params)

        self.assertEqualXml(result, self.xml_element)
Пример #2
0
 def _format_xml_request(self, request_params):
     data_set = request_params.get('data') is not None
     if request_params.get('send_as_xml') and data_set:
         data = request_params['data']
         if isinstance(data, dict):
             data = to_xml(request_params['root'], data)
         request_params['data'] = etree.tostring(
             data, encoding='utf-8', xml_declaration=True,
             pretty_print=True)
         request_params.setdefault('headers', {})
         request_params['headers']['Content-Type'] = 'application/xml'
     return request_params
Пример #3
0
 def _format_xml_request(self, request_params):
     data_set = request_params.get('data') is not None
     if request_params.get('send_as_xml') and data_set:
         data = request_params['data']
         if isinstance(data, dict):
             data = to_xml(request_params['root'], data)
         request_params['data'] = etree.tostring(
             data, encoding='utf-8', xml_declaration=True,
             pretty_print=True)
         request_params.setdefault('headers', {})
         request_params['headers']['Content-Type'] = 'application/xml'
     return request_params