def test_missing_base_response_field(self, field_name): self.remove_xml_node('./runReportResponse/' + field_name) self.on_post_return_xml() report_request = PaypalReportRequest("FooReport") with self.assertRaisesRegexp(PaypalMalformedResponseError, field_name): report_request.execute()
def test_missing_report_response(self): self.remove_xml_node('./runReportResponse') self.on_post_return_xml() report_request = PaypalReportRequest("FooReport") with self.assertRaisesRegexp(PaypalMalformedResponseError, 'runReportResponse'): report_request.execute()
def test_complete_status(self): self.on_post_return_xml() report_request = PaypalReportRequest("FooReport", report_date="2015-08-28") response = report_request.execute() self.assertEqual(response.response_code, 100) self.assertEqual(response.response_message, 'Request has completed successfully') self.assertEqual(response.report_id, 'RE12345690123') self.assertEqual(response.status_code, 3) self.assertEqual(response.status_message, 'Report has completed successfully') self.assertFalse(response.is_running) self.assertTrue(response.is_ready) self.parse_request_xml() self.assert_request_xml_equals('.', """\ <reportingEngineRequest> <authRequest> <user>testuser</user> <vendor>testvendor</vendor> <partner>testpartner</partner> <password>notsosecret</password> </authRequest> <runReportRequest> <reportName>FooReport</reportName> <reportParam> <paramName>report_date</paramName> <paramValue>2015-08-28</paramValue> </reportParam> <pageSize>50</pageSize> </runReportRequest> </reportingEngineRequest> """)
def test_unsuccessful_request(self, response_code, response_msg): self.set_xml_node_text('./baseResponse/responseCode', response_code) self.set_xml_node_text('./baseResponse/responseMsg', response_msg) self.on_post_return_xml() report_request = PaypalReportRequest("FooReport") with self.assertRaisesRegexp( PaypalApiRequestFailedError, 'API request failed with code {0}: {1}'.format( response_code, response_msg)): report_request.execute()
def test_unsuccessful_report_generation_attempt(self, status_code, status_msg): self.set_xml_node_text('./runReportResponse/statusCode', status_code) self.set_xml_node_text('./runReportResponse/statusMsg', status_msg) self.on_post_return_xml() report_request = PaypalReportRequest("FooReport") with self.assertRaisesRegexp( PaypalApiRequestFailedError, 'report request failed with code {0}: {1}'.format( status_code, status_msg)): report_request.execute()
def test_executing_status(self, status_code, status_msg): self.set_xml_node_text('./runReportResponse/statusCode', status_code) self.set_xml_node_text('./runReportResponse/statusMsg', status_msg) self.on_post_return_xml() report_request = PaypalReportRequest("FooReport") response = report_request.execute() self.assertEqual(response.status_code, status_code) self.assertEqual(response.status_message, status_msg) self.assertTrue(response.is_running) self.assertFalse(response.is_ready)
def test_unsuccessful_report_generation_attempt(self, status_code, status_msg): self.set_xml_node_text('./runReportResponse/statusCode', status_code) self.set_xml_node_text('./runReportResponse/statusMsg', status_msg) self.on_post_return_xml() report_request = PaypalReportRequest("FooReport") with self.assertRaisesRegexp( PaypalApiRequestFailedError, 'report request failed with code {0}: {1}'.format( status_code, status_msg ) ): report_request.execute()
def test_unsuccessful_request(self, response_code, response_msg): self.set_xml_node_text('./baseResponse/responseCode', response_code) self.set_xml_node_text('./baseResponse/responseMsg', response_msg) self.on_post_return_xml() report_request = PaypalReportRequest("FooReport") with self.assertRaisesRegexp( PaypalApiRequestFailedError, 'API request failed with code {0}: {1}'.format( response_code, response_msg ) ): report_request.execute()