class DeclinedResponseTests(TestCase): def setUp(self): request_xml = "" response_xml = """<?xml version="1.0" encoding="UTF-8"?> <Response> <CardTxn> <authcode>DECLINED</authcode> <card_scheme>Mastercard</card_scheme> <country>United Kingdom</country> </CardTxn> <datacash_reference>4400200045583767</datacash_reference> <merchantreference>AA004630</merchantreference> <mode>TEST</mode> <reason>DECLINED</reason> <status>7</status> <time>1169223906</time> </Response>""" self.response = Response(request_xml, response_xml) def test_is_successful(self): self.assertFalse(self.response.is_successful()) def test_is_declined(self): self.assertTrue(self.response.is_declined())
def setUp(self): request_xml = "" response_xml = """<?xml version="1.0" encoding="UTF-8"?> <Response> <datacash_reference>4500203021916406</datacash_reference> <merchantreference>4500203021916406</merchantreference> <mode>TEST</mode> <reason>CANCELLED OK</reason> <status>1</status> <time>1324832003</time> </Response>""" self.response = Response(request_xml, response_xml)
class SuccessfulResponseTests(TestCase): def setUp(self): request_xml = "" response_xml = """<?xml version="1.0" encoding="UTF-8"?> <Response> <datacash_reference>4500203021916406</datacash_reference> <merchantreference>4500203021916406</merchantreference> <mode>TEST</mode> <reason>CANCELLED OK</reason> <status>1</status> <time>1324832003</time> </Response>""" self.response = Response(request_xml, response_xml) def test_dict_access(self): self.assertEquals('1', self.response['status']) def test_in_access(self): self.assertTrue('status' in self.response) def test_is_successful(self): self.assertTrue(self.response.is_successful()) def test_status_is_returned_correctly(self): self.assertEquals(1, self.response.status)
def setUp(self): request_xml = "" response_xml = """<?xml version="1.0" encoding="UTF-8"?> <Response> <CardTxn> <authcode>DECLINED</authcode> <card_scheme>Mastercard</card_scheme> <country>United Kingdom</country> </CardTxn> <datacash_reference>4400200045583767</datacash_reference> <merchantreference>AA004630</merchantreference> <mode>TEST</mode> <reason>DECLINED</reason> <status>7</status> <time>1169223906</time> </Response>""" self.response = Response(request_xml, response_xml)
def test_none_is_returned_for_missing_status(self): r = Response('', '<?xml version="1.0" ?><Response />') self.assertIsNone(r.status)
def test_str_version_is_response_xml(self): response_xml = '<?xml version="1.0" ?><Response />' r = Response('', response_xml) self.assertEqual(response_xml, str(r))