예제 #1
0
    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()
예제 #2
0
    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()
예제 #3
0
    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()
예제 #4
0
    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>
""")
예제 #5
0
    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()
예제 #6
0
    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()
예제 #7
0
    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)
예제 #8
0
    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)
예제 #9
0
    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()
예제 #10
0
    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()