コード例 #1
0
 def test__parse_response(self):
     """Ensure _parse_response fails gracefully and with some meaning"""
     api = PaypalExpressCheckout(checkout=self.checkout)
     # go for an all out fail
     response = api._parse_response('')
     # we get something meaningful back
     self.assertEqual({'error': 'response could not be parsed'}, response)
     # pass something that can be parsed
     qs = 'foo=a&bar=b&baz=c'
     response = api._parse_response(qs)
     self.assertEqual(response, {
             'foo': 'a',
             'bar': 'b',
             'baz': 'c'
         })
     # now pass the same thing with ampersands added to throw the parse off
     qs = '&foo=a&bar=b&baz=c&'
     response = api._parse_response(qs)
     self.assertEqual(response, {
             'foo': 'a',
             'bar': 'b',
             'baz': 'c'
         })