Beispiel #1
0
    def assertXmlEqual(self, got, want):
        """ fail if the two objects are not equal XML serializations
        In case of a failure, both serializations are pretty printed
        with differences marked.
        There is not check well-formedness or against any schema, only
        slightly intelligent matching of the tested string to the reference
        string.

        '...' can be used as a wildcard instead of nodes or attribute values.

        Wildcard Examples:
            <foo>...</foo>
            <foo bar="..." />

        Arguments:
            got -- string to check, as unicode string
            want -- reference string, as unicode string

        Usage Example:
            self.assertXmlEqual(etree.tounicode(...), reference)
        """
        checker = LXMLOutputChecker()
        if not checker.check_output(want, got, 0):
            message = checker.output_difference(Example("", want), got, 0)
            raise AssertionError(message)
Beispiel #2
0
def assert_xml_equal(got, want):
    assert want is not None, 'Wanted XML cannot be None'
    if got is None:
        raise AssertionError('Got input to validate was None')
    checker = LXMLOutputChecker()
    if not checker.check_output(want, got, 0):
        message = checker.output_difference(Example("", want), got, 0)
        raise AssertionError(message)
Beispiel #3
0
def assert_xml_equal(expected_xml, got_xml):
    checker = LXMLOutputChecker()
    if not checker.check_output(expected_xml, got_xml, 0):
        raise AssertionError(checker.output_difference(
            doctest.Example("", expected_xml),
            got_xml,
            0
        ))
Beispiel #4
0
 def test_encodeEntities(self):
     doc = xtree('testdata/test_data.xml')
     doc.parse(False)
     r = xtree('testdata/r_test_encode.xml')
     r.parse(False)
     checker = LXMLOutputChecker()
     self.assertTrue(
         checker.compare_docs(r.tree.getroot(), doc.tree.getroot()))
Beispiel #5
0
def assert_xml_equal(expected_xml, got_xml, context_explanation=""):
    checker = LXMLOutputChecker()
    if not checker.check_output(expected_xml, got_xml, 0):
        raise AssertionError("{context_explanation}{xml_diff}".format(
            context_explanation=("" if not context_explanation else
                                 "\n{0}\n".format(context_explanation)),
            xml_diff=checker.output_difference(
                doctest.Example("", expected_xml), got_xml, 0)))
Beispiel #6
0
 def assertXmlEqual(self, got, want):
     if isinstance(got, (et._Element, et._ElementTree)):
         got = et.tostring(got).decode()
     if isinstance(want, (et._Element, et._ElementTree)):
         want = et.tostring(want).decode()
     checker = LXMLOutputChecker()
     if not checker.check_output(want, got, 0):
         message = checker.output_difference(Example("", want), got, 0)
         raise AssertionError(message)
Beispiel #7
0
    def test_fault_generation(self):
        class SoapException(ServiceBase):
            @srpc()
            def soap_exception():
                raise Fault("Client.Plausible", "A plausible fault",
                            'http://faultactor.example.com')

        app = Application([SoapException],
                          'tns',
                          in_protocol=Soap12(),
                          out_protocol=Soap12())

        req = b"""
        <soap12env:Envelope
                xmlns:soap12env="http://www.w3.org/2003/05/soap-envelope"
                xmlns:tns="tns">
            <soap12env:Body>
                <tns:soap_exception/>
            </soap12env:Body>
        </soap12env:Envelope>
        """

        server = WsgiApplication(app)
        response = etree.fromstring(b''.join(
            server(
                {
                    'QUERY_STRING': '',
                    'PATH_INFO': '/call',
                    'REQUEST_METHOD': 'POST',
                    'CONTENT_TYPE': 'text/xml; charset=utf8',
                    'wsgi.input': BytesIO(req)
                }, start_response, "http://null")))

        response_str = etree.tostring(response, pretty_print=True)
        print(response_str)

        expected = b"""
            <soap12env:Envelope xmlns:soap12env="http://www.w3.org/2003/05/soap-envelope">
              <soap12env:Body>
                <soap12env:Fault>
                  <soap12env:Reason>
                      <soap12env:Text xml:lang="en">A plausible fault</soap12env:Text>
                  </soap12env:Reason>
                  <soap12env:Role>http://faultactor.example.com</soap12env:Role>
                  <soap12env:Code>
                    <soap12env:Value>soap12env:Sender</soap12env:Value>
                    <soap12env:Subcode>
                      <soap12env:Value>Plausible</soap12env:Value>
                    </soap12env:Subcode>
                  </soap12env:Code>
                </soap12env:Fault>
              </soap12env:Body>
            </soap12env:Envelope>"""
        if not LXMLOutputChecker().check_output(expected, response_str,
                                                PARSE_XML):
            raise Exception("Got: %s but expected: %s" %
                            (response_str, expected))
Beispiel #8
0
def assertXmlEqual(got, want):
    from lxml.doctestcompare import LXMLOutputChecker
    from doctest import Example

    checker = LXMLOutputChecker()
    if checker.check_output(want, got, 0):
        return
    message = checker.output_difference(Example("", want), got, 0)
    raise AssertionError(message)
Beispiel #9
0
 def test_insertPIBefore(self):
     doc = xtree('testdata/test_wrap.xml')
     doc.parse(False)
     for text in doc.tree.xpath('//text'):
         pi = etree.ProcessingInstruction('PI', 'Pb')
         doc.insert_node(text, 'stuff', pi, True)
     r = xtree('testdata/r_test_insertPIBefore.xml')
     r.parse(False)
     checker = LXMLOutputChecker()
     self.assertTrue(
         checker.compare_docs(r.tree.getroot(), doc.tree.getroot()))
class DoctestCompareTest(HelperTestCase):
    _checker = LXMLOutputChecker()

    def compare(self, want, got, html=False):
        if html:
            options = PARSE_HTML
        else:
            options = PARSE_XML

        parse = self._checker.get_parser(want, got, options)
        want_doc = parse(want)
        got_doc = parse(got)
        return self._checker.collect_diff(
            want_doc, got_doc, html, indent=0).lstrip()

    def assert_diff(self, want, got, diff, html=False):
        self.assertEqual(self.compare(want, got, html), diff)

    def assert_nodiff(self, want, got, html=False):
        root = etree.fromstring(want)
        root.tail = '\n'
        indent(root)
        diff = etree.tostring(
            root, encoding='unicode', method=html and 'html' or 'xml')
        self.assert_diff(want, got, diff, html=html)

    def test_equal_input(self):
        self.assert_nodiff(
            '<p title="expected">Expected</p>',
            '<p title="expected">Expected</p>')

    def test_differing_tags(self):
        self.assert_diff(
            '<p title="expected">Expected</p>',
            '<b title="expected">Expected</b>',
            '<p (got: b) title="expected">Expected</p (got: b)>\n')

    def test_tags_upper_lower_case(self):
        self.assert_diff(
            '<p title="expected">Expected</p>',
            '<P title="expected">Expected</P>',
            '<p (got: P) title="expected">Expected</p (got: P)>\n')

    def test_tags_upper_lower_case_html(self):
        self.assert_nodiff(
            '<html><body><p title="expected">Expected</p></body></html>',
            '<HTML><BODY><P title="expected">Expected</P></BODY></HTML>',
            html=True)

    def test_differing_attributes(self):
        self.assert_diff(
            '<p title="expected">Expected</p>',
            '<p title="actual">Actual</p>',
            '<p title="expected (got: actual)">Expected (got: Actual)</p>\n')
Beispiel #11
0
def assert_xml_equal(got: Union[bytes, str], want: str):
    """Compare two XML strings."""
    checker = LXMLOutputChecker()
    if isinstance(got, str) and got.startswith("<?"):
        # Strip <?xml version='1.0' encoding="UTF-8" ?>
        got = got[got.index("?>") + 3 :]

    if not checker.check_output(want, got, PARSE_XML):
        example = Example("", "")
        example.want = want  # unencoded, avoid doctest for bytes type.
        message = checker.output_difference(example, got, PARSE_XML)
        raise AssertionError(message)
Beispiel #12
0
    def check_etree(self, conv, tostring=tostring, fromstring=fromstring):
        'Returns method(obj, xmlstring) that converts obj to XML and compares'
        checker = LXMLOutputChecker()
        eq = checker.compare_docs

        def compare(obj, *strings):
            tree = conv.etree(obj)
            self.assertEqual(len(tree), len(strings))
            for left, right in zip(tree, strings):
                if not eq(left, fromstring(right)):
                    raise AssertionError('%s != %s' % (decode(tostring(left)), right))

        return compare
    def assertXmlEquivalent(self, got, expect):
        """Asserts both xml parse to the same results
        `got` may be an XML string or lxml Element
        """
        checker = LXMLOutputChecker()

        if isinstance(got, etree._Element):
            got = etree.tostring(got)

        if not checker.check_output(expect, got, PARSE_XML):
            message = checker.output_difference(doctest.Example("", expect),
                                                got, PARSE_XML)
            self.fail(message)
Beispiel #14
0
 def test_wrap(self):
     doc = xtree('testdata/test_wrap.xml')
     doc.parse(False)
     if not doc.is_valid:
         if not doc.errors is None: print(doc.errors)
     for text in doc.tree.xpath('//text'):
         el = etree.Element('EL')
         el.set('atr', 'test')
         doc.wrap_text(text, 'text', el)
     r = xtree('testdata/r_test_wrap.xml')
     r.parse(False)
     checker = LXMLOutputChecker()
     self.assertTrue(
         checker.compare_docs(r.tree.getroot(), doc.tree.getroot()))
Beispiel #15
0
def compare_xml(generated, expected):
    """Use doctest checking from lxml for comparing XML trees. Returns diff if the two are not the same"""
    checker = LXMLOutputChecker()

    class DummyDocTest():
        pass

    ob = DummyDocTest()
    ob.want = expected

    check = checker.check_output(expected, generated, PARSE_XML)
    if check is False:
        diff = checker.output_difference(ob, generated, PARSE_XML)
        return diff
Beispiel #16
0
def assertEqualXML(test, expected):
    output_checker = LXMLOutputChecker()
    if not output_checker.check_output(expected, test, PARSE_XML):
        diff = output_checker.output_difference(Example("", expected), test,
                                                PARSE_XML)
        msg = diff
        for line in diff.split("\n"):
            if msg == diff:
                msg = msg + "\nDiff summary:\n"
            if "got:" in line or line.strip().startswith(('+', '-')):
                msg = msg + line + "\n"
        if msg == "":
            msg = diff
        raise AssertionError(msg)
    def assertXmlEquivalentOutputs(self, data, expected):
        """Asserts both XML outputs are equivalent.

        This assertion use the powerful but dangerous feature of
        LXMLOutputChecker. Powerful because one can compare two XML document
        in their meaning, but dangerous because sometimes there is more to
        check than just a kind of output.

        See LXMLOutputChecker documentation for more information.

        """
        checker = LXMLOutputChecker()

        if not checker.check_output(expected, data, PARSE_XML):
            self.fail('Output are not equivalent:\n'
                      'Given: %s\n'
                      'Expected: %s' % (data, expected))
Beispiel #18
0
    def assertXmlEqual(self, expected, actual, normalize=True):
        if normalize:
            parser = lxml.etree.XMLParser(remove_blank_text=True)
            parse = lambda *args: normalize_attributes(lxml.etree.XML(*args))
            expected = lxml.etree.tostring(parse(expected, parser), pretty_print=True)
            actual = lxml.etree.tostring(parse(actual, parser), pretty_print=True)

        # snippet from http://stackoverflow.com/questions/321795/comparing-xml-in-a-unit-test-in-python/7060342#7060342
        checker = LXMLOutputChecker()
        if not checker.check_output(expected, actual, 0):
            message = "XML mismatch\n\n"
            diff = difflib.unified_diff(
                expected.splitlines(1),
                actual.splitlines(1),
                fromfile='want.xml',
                tofile='got.xml'
            )
            for line in diff:
                message += line
            raise AssertionError(message)
Beispiel #19
0
def test_receiveItemBarCode_soap():
    from io import BytesIO

    from lxml import etree
    from lxml.doctestcompare import LXMLOutputChecker, PARSE_XML
    from spyne import srpc, Array, Integer, ServiceBase
    from spyne.protocol.soap import Soap11
    from spyne.server.wsgi import WsgiApplication

    from soapser import NAMESPACE

    req = b"""
    <soap11env:Envelope
        xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/">
      <soap11env:Body>
        <s0:receiveItemBarCode xmlns:s0="Flow/Services/Custom">
          <s0:tXml>
            <s0:Header>
              <s0:Message_Type>mt</s0:Message_Type>
              <s0:Company_ID>ci</s0:Company_ID>
              <s0:Version>v</s0:Version>
              <s0:Source>s</s0:Source>
              <s0:Destination>d</s0:Destination>
              <s0:Action_Type>read</s0:Action_Type>
              <s0:Sequence_Number>1</s0:Sequence_Number>
              <s0:Batch_ID>bi</s0:Batch_ID>
              <s0:Reference_ID>ri</s0:Reference_ID>
              <s0:Msg_Locale>ml</s0:Msg_Locale>
              <s0:Msg_Time_Zone>mtz</s0:Msg_Time_Zone>
              <s0:Internal_Date_Time_Stamp>idts</s0:Internal_Date_Time_Stamp>
            </s0:Header>
            <s0:Message>
              <s0:ItemBarCodeList>
                <s0:ItemBarCode>
                  <s0:IsPrimary>ip</s0:IsPrimary>
                  <s0:ItemCode>ic</s0:ItemCode>
                  <s0:Barcode>b</s0:Barcode>
                  <s0:Quantity>q</s0:Quantity>
                  <s0:ActionType>at</s0:ActionType>
                  <s0:BarcodeType>bt</s0:BarcodeType>
                  <s0:Extensions>
                    <s0:FieldCode>fc</s0:FieldCode>
                    <s0:FieldCodeDesc>fcd</s0:FieldCodeDesc>
                    <s0:FieldValue>fv</s0:FieldValue>
                  </s0:Extensions>
                  <s0:Extensions>
                    <s0:FieldCode>fc</s0:FieldCode>
                    <s0:FieldCodeDesc>fcd</s0:FieldCodeDesc>
                    <s0:FieldValue>fv</s0:FieldValue>
                  </s0:Extensions>
                </s0:ItemBarCode>
                <s0:ItemBarCode>
                  <s0:IsPrimary>ip</s0:IsPrimary>
                  <s0:ItemCode>ic</s0:ItemCode>
                  <s0:Barcode>b</s0:Barcode>
                  <s0:Quantity>q</s0:Quantity>
                  <s0:ActionType>at</s0:ActionType>
                  <s0:BarcodeType>bt</s0:BarcodeType>
                  <s0:Extensions>
                    <s0:FieldCode>fc</s0:FieldCode>
                    <s0:FieldCodeDesc>fcd</s0:FieldCodeDesc>
                    <s0:FieldValue>fv</s0:FieldValue>
                  </s0:Extensions>
                  <s0:Extensions>
                    <s0:FieldCode>fc</s0:FieldCode>
                    <s0:FieldCodeDesc>fcd</s0:FieldCodeDesc>
                    <s0:FieldValue>fv</s0:FieldValue>
                  </s0:Extensions>
                </s0:ItemBarCode>
              </s0:ItemBarCodeList>
            </s0:Message>
          </s0:tXml>
        </s0:receiveItemBarCode>
      </soap11env:Body>
    </soap11env:Envelope>
    """

    app = Application([rpc.receiveItemBarCodeService],
                      NAMESPACE,
                      in_protocol=Soap11(validator='lxml'),
                      out_protocol=Soap11(validator='lxml'))
    server = WsgiApplication(app)
    response = b''.join(
        server(
            {
                #'QUERY_STRING': '',
                #'PATH_INFO': '/call',
                'REQUEST_METHOD': 'POST',
                'CONTENT_TYPE': 'text/xml',
                'wsgi.input': BytesIO(req)
            },
            lambda a, b: None,
            "http://null"))

    expected = b"""
        <soap11env:Envelope
            xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/">
          <soap11env:Body>
            <s0:receiveItemBarCodeResponse xmlns:s0="Flow/Services/Custom">
              <s0:receiveItemBarCodeResult>true</s0:receiveItemBarCodeResult>
              <s0:responseHeader>
                <s0:ReturnType>ItemCrossReference</s0:ReturnType>
                <s0:ReturnCode>Success</s0:ReturnCode>
                <s0:ReturnMessage>
                  ItemCrossReference Interface Process Completed Successfully
                </s0:ReturnMessage>
              </s0:responseHeader>
            </s0:receiveItemBarCodeResponse>
          </soap11env:Body>
        </soap11env:Envelope>"""
    if not LXMLOutputChecker().check_output(expected, response, PARSE_XML):
        raise Exception("Got: %s but expected: %s" % (response, expected))
	def assertXmlEqual(self, want, got):
		checker = LXMLOutputChecker()
		if not checker.check_output(want, got, 0):
			message = checker.output_difference(Example("", want), got, 0)
			raise AssertionError(message)
Beispiel #21
0
class DoctestCompareTest(HelperTestCase):
    _checker = LXMLOutputChecker()

    def compare(self, want, got, html=False):
        if html:
            options = PARSE_HTML
        else:
            options = PARSE_XML

        parse = self._checker.get_parser(want, got, options)
        want_doc = parse(want)
        got_doc = parse(got)
        return self._checker.collect_diff(want_doc, got_doc, html,
                                          indent=0).lstrip()

    def assert_diff(self, want, got, diff, html=False):
        self.assertEqual(self.compare(want, got, html), diff)

    def assert_nodiff(self, want, got, html=False):
        root = etree.fromstring(want)
        root.tail = '\n'
        indent(root)
        diff = etree.tostring(root,
                              encoding='unicode',
                              method=html and 'html' or 'xml')
        self.assert_diff(want, got, diff, html=html)

    def test_equal_input(self):
        self.assert_nodiff('<p title="expected">Expected</p>',
                           '<p title="expected">Expected</p>')

    def test_differing_tags(self):
        self.assert_diff(
            '<p title="expected">Expected</p>',
            '<b title="expected">Expected</b>',
            '<p (got: b) title="expected">Expected</p (got: b)>\n')

    def test_tags_upper_lower_case(self):
        self.assert_diff(
            '<p title="expected">Expected</p>',
            '<P title="expected">Expected</P>',
            '<p (got: P) title="expected">Expected</p (got: P)>\n')

    def test_tags_upper_lower_case_html(self):
        self.assert_nodiff(
            '<html><body><p title="expected">Expected</p></body></html>',
            '<HTML><BODY><P title="expected">Expected</P></BODY></HTML>',
            html=True)

    def test_differing_attributes(self):
        self.assert_diff(
            '<p title="expected">Expected</p>', '<p title="actual">Actual</p>',
            '<p title="expected (got: actual)">Expected (got: Actual)</p>\n')

    def test_extra_children(self):
        # https://bugs.launchpad.net/lxml/+bug/1238503
        self.assert_diff(
            '<p><span>One</span></p>',
            '<p><span>One</span><b>Two</b><em>Three</em></p>', '<p>\n'
            '  <span>One</span>\n'
            '  +<b>Two</b>\n'
            '  +<em>Three</em>\n'
            '</p>\n')

    def test_missing_children(self):
        self.assert_diff(
            '<p><span>One</span><b>Two</b><em>Three</em></p>',
            '<p><span>One</span></p>', '<p>\n'
            '  <span>One</span>\n'
            '  -<b>Two</b>\n'
            '  -<em>Three</em>\n'
            '</p>\n')

    def test_extra_attributes(self):
        self.assert_diff(
            '<p><span class="foo">Text</span></p>',
            '<p><span class="foo" id="bar">Text</span></p>', '<p>\n'
            '  <span class="foo" +id="bar">Text</span>\n'
            '</p>\n')

    def test_missing_attributes(self):
        self.assert_diff(
            '<p><span class="foo" id="bar">Text</span></p>',
            '<p><span class="foo">Text</span></p>', '<p>\n'
            '  <span class="foo" -id="bar">Text</span>\n'
            '</p>\n')
Beispiel #22
0
 def setUp(self):
     self.checker = LXMLOutputChecker()
Beispiel #23
0
def assert_xml_equals(reference, result):
    """Compare if XML documents are equal except formatting."""
    checker = LXMLOutputChecker()
    if not checker.check_output(reference, result, 0):
        message = checker.output_difference(Example("", reference), result, 0)
        pytest.fail(message)
Beispiel #24
0
 def assertXmlEqual(self, expected, actual, normalize=True):
     if normalize:
         expected = parse_normalize(expected)
         actual = parse_normalize(actual)
     _check_shared(expected, actual, LXMLOutputChecker(), "xml")
Beispiel #25
0
def test_receiveItemMaster_soap():
    from io import BytesIO

    from lxml import etree
    from lxml.doctestcompare import LXMLOutputChecker, PARSE_XML
    from spyne import srpc, Array, Integer, ServiceBase
    from spyne.protocol.soap import Soap11
    from spyne.server.wsgi import WsgiApplication

    from soapser import NAMESPACE

    req = b"""
    <soap11env:Envelope
        xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/">
      <soap11env:Body>
        <s0:receiveItemMaster xmlns:s0="Flow/Services/Custom">
          <s0:tXml>
            <s0:Header>
              <s0:Message_Type>mt</s0:Message_Type>
              <s0:Company_ID>ci</s0:Company_ID>
              <s0:Version>v</s0:Version>
              <s0:Source>s</s0:Source>
              <s0:Destination>d</s0:Destination>
              <s0:Action_Type>read</s0:Action_Type>
              <s0:Sequence_Number>1</s0:Sequence_Number>
              <s0:Batch_ID>bi</s0:Batch_ID>
              <s0:Reference_ID>ri</s0:Reference_ID>
              <s0:Msg_Locale>ml</s0:Msg_Locale>
              <s0:Msg_Time_Zone>mtz</s0:Msg_Time_Zone>
              <s0:Internal_Date_Time_Stamp>idts</s0:Internal_Date_Time_Stamp>
            </s0:Header>
            <s0:Message>
              <s0:Item>
                <s0:ItemCode>ic</s0:ItemCode>
                <s0:IsStyle>is</s0:IsStyle>
                <s0:ActionType>at</s0:ActionType>
                <s0:ActivationDate>ad</s0:ActivationDate>
                <s0:TargetExclusive>te</s0:TargetExclusive>
                <s0:OnlineExclusive>oe</s0:OnlineExclusive>
                <s0:EssentialItem>ei</s0:EssentialItem>
                <s0:LongDescription>ld</s0:LongDescription>
                <s0:ShortDescription>sd</s0:ShortDescription>
                <s0:PrimaryBarcode>pb</s0:PrimaryBarcode>
                <s0:HazmatCode>hc</s0:HazmatCode>
                <s0:BulkyItem>bi</s0:BulkyItem>
                <s0:ItemWeight>iw</s0:ItemWeight>
                <s0:ItemHeight>ih</s0:ItemHeight>
                <s0:ItemLength>il</s0:ItemLength>
                <s0:ItemWidth>iw</s0:ItemWidth>
                <s0:ItemVolume>iv</s0:ItemVolume>
                <s0:WeightUOM>wu</s0:WeightUOM>
                <s0:DimensionUOM>du</s0:DimensionUOM>
                <s0:VolumeUOM>vu</s0:VolumeUOM>
                <s0:IsPerishable>ip</s0:IsPerishable>
                <s0:ItemPackageList>
                  <s0:ItemPackage>
                    <s0:PackageType>pt</s0:PackageType>
                    <s0:Description>d</s0:Description>
                    <s0:Quantity>q</s0:Quantity>
                    <s0:UnitWeight>uw</s0:UnitWeight>
                    <s0:UnitWidth>uw</s0:UnitWidth>
                    <s0:UnitLength>ul</s0:UnitLength>
                    <s0:UnitHeight>uh</s0:UnitHeight>
                    <s0:UnitVolume>uv</s0:UnitVolume>
                    <s0:WeigthUOM>wu</s0:WeigthUOM>
                    <s0:DimensionUOM>du</s0:DimensionUOM>
                    <s0:VolumeUOM>vu</s0:VolumeUOM>
                    <s0:IsPrimary>ip</s0:IsPrimary>
                    <s0:BusinessPartnerNumber>bpn</s0:BusinessPartnerNumber>
                    <s0:Ti>ti</s0:Ti>
                    <s0:Hi>hi</s0:Hi>
                  </s0:ItemPackage>
                </s0:ItemPackageList>
                <s0:ProductHeirarchy>
                  <s0:Variant>v</s0:Variant>
                  <s0:Product>p</s0:Product>
                  <s0:MerchandiseStyle>ms</s0:MerchandiseStyle>
                  <s0:Range>r</s0:Range>
                  <s0:MajorClass>mc</s0:MajorClass>
                  <s0:ClassGroup>cg</s0:ClassGroup>
                  <s0:Department>d</s0:Department>
                  <s0:BusinessGroup>bg</s0:BusinessGroup>
                  <s0:Section>s</s0:Section>
                  <s0:Company>c</s0:Company>
                </s0:ProductHeirarchy>
                <s0:ItemBarCodeList>
                  <s0:ItemBarCode>
                    <s0:IsPrimary>ip</s0:IsPrimary>
                    <s0:Barcode>b</s0:Barcode>
                    <s0:Quantity>q</s0:Quantity>
                    <s0:ActionType>at</s0:ActionType>
                    <s0:BarcodeType>bt</s0:BarcodeType>
                  </s0:ItemBarCode>
                  <s0:ItemBarCode>
                    <s0:IsPrimary>ip</s0:IsPrimary>
                    <s0:Barcode>b</s0:Barcode>
                    <s0:Quantity>q</s0:Quantity>
                    <s0:ActionType>at</s0:ActionType>
                    <s0:BarcodeType>bt</s0:BarcodeType>
                  </s0:ItemBarCode>
                </s0:ItemBarCodeList>
                <s0:PerishableAttribute>
                  <s0:ShelfDays>sd</s0:ShelfDays>
                  <s0:ExpireDateReqd>edr</s0:ExpireDateReqd>
                  <s0:MinReceivedToExpireDays>mrted</s0:MinReceivedToExpireDays>
                  <s0:MaxReceivedToExpireDays>mrted</s0:MaxReceivedToExpireDays>
                </s0:PerishableAttribute>
                <s0:WarehouseAttributes>
                  <s0:SecureProduct>sp</s0:SecureProduct>
                  <s0:Conveyable>c</s0:Conveyable>
                  <s0:PutawayType>pt</s0:PutawayType>
                  <s0:CrushCode>cc</s0:CrushCode>
                  <s0:VolatilityCode>vc</s0:VolatilityCode>
                </s0:WarehouseAttributes>
                <s0:Slotting>
                  <s0:LocationCode>lc</s0:LocationCode>
                  <s0:SlottingRequired>sr</s0:SlottingRequired>
                </s0:Slotting>
                <s0:Slotting>
                  <s0:LocationCode>lc</s0:LocationCode>
                  <s0:SlottingRequired>sr</s0:SlottingRequired>
                </s0:Slotting>
                <s0:ItemPromotion>
                  <s0:OnPromo>op</s0:OnPromo>
                  <s0:PromoStartWeek>psw</s0:PromoStartWeek>
                </s0:ItemPromotion>
                <s0:ItemAttributes>
                  <s0:AttributeTypeId>ati</s0:AttributeTypeId>
                  <s0:AttributeTypeDesc>atd</s0:AttributeTypeDesc>
                  <s0:AttributeHeaderId>ahi</s0:AttributeHeaderId>
                  <s0:AttributeHeaderDesc>ahd</s0:AttributeHeaderDesc>
                  <s0:AttributeCodeId>aci</s0:AttributeCodeId>
                  <s0:AttributeCode>ac</s0:AttributeCode>
                  <s0:AttributeCodeDesc>acd</s0:AttributeCodeDesc>
                </s0:ItemAttributes>
                <s0:ItemAttributes>
                  <s0:AttributeTypeId>ati</s0:AttributeTypeId>
                  <s0:AttributeTypeDesc>atd</s0:AttributeTypeDesc>
                  <s0:AttributeHeaderId>ahi</s0:AttributeHeaderId>
                  <s0:AttributeHeaderDesc>ahd</s0:AttributeHeaderDesc>
                  <s0:AttributeCodeId>aci</s0:AttributeCodeId>
                  <s0:AttributeCode>ac</s0:AttributeCode>
                  <s0:AttributeCodeDesc>acd</s0:AttributeCodeDesc>
                </s0:ItemAttributes>
                <s0:Extensions>
                  <s0:FieldCode>fc</s0:FieldCode>
                  <s0:FieldCodeDesc>fcd</s0:FieldCodeDesc>
                  <s0:FieldValue>fv</s0:FieldValue>
                </s0:Extensions>
                <s0:Extensions>
                  <s0:FieldCode>fc</s0:FieldCode>
                  <s0:FieldCodeDesc>fcd</s0:FieldCodeDesc>
                  <s0:FieldValue>fv</s0:FieldValue>
                </s0:Extensions>
              </s0:Item>
            </s0:Message>
          </s0:tXml>
        </s0:receiveItemMaster>
      </soap11env:Body>
    </soap11env:Envelope>
    """

    app = Application([rpc.receiveItemMasterService],
                      NAMESPACE,
                      in_protocol=Soap11(validator='lxml'),
                      out_protocol=Soap11(validator='lxml'))
    server = WsgiApplication(app)
    response = b''.join(
        server(
            {
                #'QUERY_STRING': '',
                #'PATH_INFO': '/call',
                'REQUEST_METHOD': 'POST',
                'CONTENT_TYPE': 'text/xml',
                'wsgi.input': BytesIO(req)
            },
            lambda a, b: None,
            "http://null"))

    expected = b"""
        <soap11env:Envelope
            xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/">
          <soap11env:Body>
            <s0:receiveItemMasterResponse xmlns:s0="Flow/Services/Custom">
              <s0:receiveItemMasterResult>true</s0:receiveItemMasterResult>
              <s0:responseHeader>
                <s0:ReturnType>Item Master</s0:ReturnType>
                <s0:ReturnCode>Success</s0:ReturnCode>
                <s0:ReturnMessage>
                  Item Master Interface Process Completed Successfully
                </s0:ReturnMessage>
              </s0:responseHeader>
            </s0:receiveItemMasterResponse>
          </soap11env:Body>
        </soap11env:Envelope>"""
    if not LXMLOutputChecker().check_output(expected, response, PARSE_XML):
        raise Exception("Got: %s but expected: %s" % (response, expected))