Exemplo n.º 1
0
 def test_general_examples(self):
     """
     Test that response parser don't break with example patterns
     given by Authorize.Net
     """
     examples = file(j(up(os.path.abspath(__file__)), 'CIMXMLExamples.txt')).read().split(DELIMITER)
     for example in examples:
         example = example.strip()
         try:
             resp = x.to_dict(example, responses.cim_map)
         except responses.AuthorizeError:
             resp = x.to_dict(example, responses.cim_map, do_raise=False)
             assert resp.messages.message.code.text_ in responses.cim_map
         else:
             assert resp.messages.message.code.text_ == u'I00001'
Exemplo n.º 2
0
 def parse_response(self, response):
     """
     Parse the response from the web service, check also if we want
     to raise the error as opposed to return an error object.
     """
     return xml.to_dict(response, self.responses, self.do_raise,
                        self.delimiter, self.encapsulator, self.uniform)
Exemplo n.º 3
0
    def test_parse_direct_response(self):
        """
        The direct response string returned by Authorize.net can be
        quite interesting to parse. We verify that it is correctly
        handled.
        """
        response = """\
<?xml version="1.0" encoding="utf-8"?>
<createCustomerProfileTransactionResponse xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
  <messages>
    <resultCode>Ok</resultCode>
    <message>
      <code>I00001</code>
      <text>Successful.</text>
    </message>
  </messages>
  <directResponse>*1*;*1*;*1*;*This transaction has been approved.*;*000000*;*Y*;*2000000001*;*INV000001*;*description of transaction*;*10.95*;*CC*;*auth_capture*;*custId123*;*John*;*Doe*;**;*123 Main St., foo*;*Bellevue*;*WA*;*98004*;*USA*;*000-000-0000*;**;*[email protected]*;*John*;*Doe*;**;*123 Main St.*;*Bellevue*;*WA*;*98004*;*USA*;*1.00*;*0.00*;*2.00*;*FALSE*;*PONUM000001*;*D18EB6B211FE0BBF556B271FDA6F92EE*;*M*;*buaaahahah , *;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;*wallers,*</directResponse>
</createCustomerProfileTransactionResponse>"""
        resp = x.to_dict(response,
                         responses.cim_map,
                         delimiter=u";",
                         encapsulator=u"*")
        assert resp.direct_response.code == u"1"
        assert resp.direct_response.address == u"123 Main St., foo"
        assert resp.direct_response.holder_verification == u"buaaahahah , "
Exemplo n.º 4
0
 def test_general_examples(self):
     """
     Test that response parser don't break with example patterns
     given by Authorize.Net
     """
     examples = file(j(up(os.path.abspath(__file__)),
                       'CIMXMLExamples.txt')).read().split(DELIMITER)
     for example in examples:
         example = example.strip()
         try:
             resp = x.to_dict(example, responses.cim_map)
         except responses.AuthorizeError:
             resp = x.to_dict(example, responses.cim_map, do_raise=False)
             assert resp.messages.message.code.text_ in responses.cim_map
         else:
             assert resp.messages.message.code.text_ == u'I00001'
Exemplo n.º 5
0
    def test_parser_to_dict(self):
        """
        Test that the dict parser works as expected
        """
        xml = """\
<foo>
    <bar>baz</bar>
    <quz>
        <wow>works!</wow>
    </quz>
</foo>
"""
        d = x.to_dict(xml, {})
        assert d.bar.text_ == u'baz'
        assert d.quz.wow.text_ == u'works!'
Exemplo n.º 6
0
    def test_parser_to_dict(self):
        """
        Test that the dict parser works as expected
        """
        xml = """\
<foo>
    <bar>baz</bar>
    <quz>
        <wow>works!</wow>
    </quz>
</foo>
"""
        d = x.to_dict(xml, {})
        assert d.bar.text_ == u'baz'
        assert d.quz.wow.text_ == u'works!'
Exemplo n.º 7
0
    def test_parse_direct_response(self):
        """
        The direct response string returned by Authorize.net can be
        quite interesting to parse. We verify that it is correctly
        handled.
        """
        response = """\
<?xml version="1.0" encoding="utf-8"?>
<createCustomerProfileTransactionResponse xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
  <messages>
    <resultCode>Ok</resultCode>
    <message>
      <code>I00001</code>
      <text>Successful.</text>
    </message>
  </messages>
  <directResponse>*1*;*1*;*1*;*This transaction has been approved.*;*000000*;*Y*;*2000000001*;*INV000001*;*description of transaction*;*10.95*;*CC*;*auth_capture*;*custId123*;*John*;*Doe*;**;*123 Main St., foo*;*Bellevue*;*WA*;*98004*;*USA*;*000-000-0000*;**;*[email protected]*;*John*;*Doe*;**;*123 Main St.*;*Bellevue*;*WA*;*98004*;*USA*;*1.00*;*0.00*;*2.00*;*FALSE*;*PONUM000001*;*D18EB6B211FE0BBF556B271FDA6F92EE*;*M*;*buaaahahah , *;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;**;*wallers,*</directResponse>
</createCustomerProfileTransactionResponse>"""
        resp = x.to_dict(response, responses.cim_map, delimiter=u";", encapsulator=u"*")
        assert resp.direct_response.code == u"1"
        assert resp.direct_response.address == u"123 Main St., foo"
        assert resp.direct_response.holder_verification == u"buaaahahah , "