예제 #1
0
    def test_malformed_column_metadata(self, field_name):
        self.remove_xml_node('./getMetaDataResponse/columnMetaData[@colNum="1"]/' + field_name)
        self.on_post_return_xml()

        request = PaypalReportMetadataRequest("RE1234567890")
        with self.assertRaisesRegexp(PaypalMalformedResponseError, field_name):
            request.execute()
예제 #2
0
    def test_missing_metadata_response(self):
        self.remove_xml_node('./getMetaDataResponse')
        self.on_post_return_xml()

        request = PaypalReportMetadataRequest("RE1234567890")
        with self.assertRaisesRegexp(PaypalMalformedResponseError, 'getMetaDataResponse'):
            request.execute()
예제 #3
0
    def test_successful_response(self):
        self.on_post_return_xml()

        request = PaypalReportMetadataRequest("RE1234567890")
        response = request.execute()

        self.assertEqual(response.response_code, 100)
        self.assertEqual(response.response_message, 'Request has completed successfully')
        self.assertEqual(response.num_rows, 102)
        self.assertEqual(response.num_pages, 3)
        self.assertEqual(response.page_size, 50)
        self.assertEqual(response.columns.popitem(last=False), ('Transaction ID', ColumnMetadata(name='Transaction ID', data_type='string')))
        self.assertEqual(response.columns.popitem(last=False), ('Time', ColumnMetadata(name='Time', data_type='date')))
        self.assertEqual(response.columns.popitem(last=False), ('Type', ColumnMetadata(name='Type', data_type='string')))

        self.parse_request_xml()
        self.assert_request_xml_equals('./getMetaDataRequest', """\
<getMetaDataRequest>
    <reportId>RE1234567890</reportId>
</getMetaDataRequest>
""")