

def test_paypal_customer_parse(self):
    customers_xml = self.load_file('paypal_customer.xml')
    parser = CustomersParser()
    expected = [{
        'campaign_content': '',
        'campaign_medium': '',
        'campaign_name': '',
        'campaign_source': '',
        'campaign_term': '',
        'code': 'test',
        'company': '',
        'created_datetime': datetime(2011, 5, 16, 16, 36, 1, tzinfo=tzutc()),
        'email': 'garbage@saaspire.com',
        'first_contact_datetime': None,
        'first_name': 'Test',
        'gateway_token': None,
        'id': '95d7696a-7fda-11e0-a51b-40403c39f8d9',
        'is_vat_exempt': '0',
        'last_name': 'User',
        'meta_data': [],
        'modified_datetime': datetime(2011, 5, 16, 16, 36, 1, tzinfo=tzutc()),
        'notes': '',
        'referer': '',
        'referer_host': '',
        'subscriptions': [{
            'cancel_reason': 'PayPal preapproval is pending',
            'cancel_type': 'paypal-wait',
            'canceled_datetime': datetime(2011, 5, 16, 16, 36, 1, tzinfo=tzutc()),
            'cc_address': '',
            'cc_city': '',
            'cc_company': '',
            'cc_country': '',
            'cc_email': '',
            'cc_expiration_date': '2012-05-16T00:00:00+00:00',
            'cc_first_name': 'Test',
            'cc_last_four': '',
            'cc_last_name': 'User',
            'cc_state': '',
            'cc_type': '',
            'cc_zip': '',
            'created_datetime': datetime(2011, 5, 16, 16, 36, 1, tzinfo=tzutc()),
            'gateway_account': {
                'gateway': 'PayPal_Simulator',
                'id': '303f9a50-7fda-11e0-a51b-40403c39f8d9',
                'type': 'paypal',
            },
            'gateway_token': 'SIMULATED-4dd152718371a',
            'id': '95d804ba-7fda-11e0-a51b-40403c39f8d9',
            'invoices': [{
                'billing_datetime': datetime(2011, 6, 16, 16, 36, 1, tzinfo=tzutc()),
                'charges': [{
                    'code': 'PAID_MONTHLY_RECURRING',
                    'created_datetime': datetime(2011, 6, 16, 16, 36, 1, tzinfo=tzutc()),
                    'description': '',
                    'each_amount': Decimal('20.00'),
                    'id': '',
                    'quantity': Decimal('1'),
                    'type': 'recurring',
                }],
                'created_datetime': datetime(2011, 5, 16, 16, 36, 1, tzinfo=tzutc()),
                'id': '95de499c-7fda-11e0-a51b-40403c39f8d9',
                'number': '1',
                'paid_transaction_id': '',
                'type': 'subscription',
                'vat_rate': '',
            }],
            'items': [{
                'code': 'MONTHLY_ITEM',
                'created_datetime': None,
                'id': 'd19b4970-6e5a-102e-b098-40402145ee8b',
                'modified_datetime': None,
                'name': 'Monthly Item',
                'quantity': Decimal('0'),
            }, {
                'code': 'ONCE_ITEM',
                'created_datetime': None,
                'id': 'd19ef2f0-6e5a-102e-b098-40402145ee8b',
                'modified_datetime': None,
                'name': 'Once Item',
                'quantity': Decimal('0'),
            }],
            'plans': [{
                'billing_frequency': 'monthly',
                'billing_frequency_per': 'month',
                'billing_frequency_quantity': 1,
                'billing_frequency_unit': 'months',
                'code': 'PAID_MONTHLY',
                'created_datetime': datetime(2011, 1, 7, 21, 5, 42, tzinfo=tzutc()),
                'description': '',
                'id': '11af9cfc-6bf2-102e-b098-40402145ee8b',
                'initial_bill_count': 1,
                'initial_bill_count_unit': 'months',
                'is_active': True,
                'is_free': False,
                'items': [{
                    'code': 'MONTHLY_ITEM',
                    'created_datetime': datetime(2011, 1, 10, 22, 40, 34, tzinfo=tzutc()),
                    'id': 'd19b4970-6e5a-102e-b098-40402145ee8b',
                    'is_periodic': False,
                    'name': 'Monthly Item',
                    'overage_amount': Decimal('0.00'),
                    'quantity_included': Decimal('0'),
                }, {
                    'code': 'ONCE_ITEM',
                    'created_datetime': datetime(2011, 1, 10, 22, 40, 34, tzinfo=tzutc()),
                    'id': 'd19ef2f0-6e5a-102e-b098-40402145ee8b',
                    'is_periodic': False,
                    'name': 'Once Item',
                    'overage_amount': Decimal('0.00'),
                    'quantity_included': Decimal('0'),
                }],
                'name': 'Paid Monthly',
                'recurring_charge_amount': Decimal('20.00'),
                'recurring_charge_code': 'PAID_MONTHLY_RECURRING',
                'setup_charge_amount': Decimal('0.00'),
                'setup_charge_code': '',
                'trial_days': 0,
            }],
            'redirect_url': 'https://cheddargetter.com/service/paypal/simulate/productId/2ccbecd6-6beb-102e-b098-40402145ee8b/id/95d7696a-7fda-11e0-a51b-40403c39f8d9?preapprovalkey=SIMULATED-4dd152718371a',
        }],
        'vat_number': '',
    }]
    result = parser.parse_xml(customers_xml)
    import pprint
    pp = pprint.PrettyPrinter(indent=4)
    pp.pprint(result)
    self.assertEquals(expected, result)

dataset/ETHPy150Open SeanOC/sharpy/tests/parser_tests.py ParserTests.test_paypal_customer_parse/original