

def test_customers_parser_with_items(self):
    customers_xml = self.load_file('customers-with-items.xml')
    parser = CustomersParser()
    expected = [{
        'campaign_content': '',
        'campaign_medium': '',
        'campaign_name': '',
        'campaign_source': '',
        'campaign_term': '',
        'code': 'test',
        'company': '',
        'created_datetime': datetime(2011, 1, 10, 23, 57, 58, tzinfo=tzutc()),
        'email': 'garbage@saaspire.com',
        'first_contact_datetime': None,
        'first_name': 'Test',
        'gateway_token': None,
        'id': 'a1f143e0-6e65-102e-b098-40402145ee8b',
        'is_vat_exempt': '0',
        'last_name': 'User',
        'meta_data': [],
        'modified_datetime': datetime(2011, 1, 10, 23, 57, 58, tzinfo=tzutc()),
        'notes': '',
        'referer': '',
        'referer_host': '',
        'subscriptions': [{
            'cancel_reason': None,
            'cancel_type': None,
            'canceled_datetime': None,
            'cc_address': '123 Something St',
            'cc_city': 'Someplace',
            'cc_company': 'Some Co LLC',
            'cc_country': 'United States',
            'cc_email': None,
            'cc_expiration_date': '2011-07-31T00:00:00+00:00',
            'cc_first_name': 'Test',
            'cc_last_four': '1111',
            'cc_last_name': 'User',
            'cc_state': 'NY',
            'cc_type': 'visa',
            'cc_zip': '12345',
            'created_datetime': datetime(2011, 1, 10, 23, 57, 58, tzinfo=tzutc()),
            'gateway_token': 'SIMULATED',
            'id': 'a1f27c60-6e65-102e-b098-40402145ee8b',
            'invoices': [{
                'billing_datetime': datetime(2011, 2, 10, 23, 57, 58, tzinfo=tzutc()),
                'charges': [{
                    'code': 'TRACKED_MONTHLY_RECURRING',
                    'created_datetime': datetime(2011, 2, 10, 23, 57, 58, tzinfo=tzutc()),
                    'description': '',
                    'each_amount': Decimal('10.00'),
                    'id': '',
                    'quantity': Decimal('1'),
                    'type': 'recurring',
                }, {
                    'code': 'MONTHLY_ITEM',
                    'created_datetime': datetime(2011, 1, 10, 23, 57, 58, tzinfo=tzutc()),
                    'description': '',
                    'each_amount': Decimal('10.00'),
                    'id': '',
                    'quantity': Decimal('1'),
                    'type': 'item',
                }, {
                    'code': 'ONCE_ITEM',
                    'created_datetime': datetime(2011, 1, 10, 23, 57, 58, tzinfo=tzutc()),
                    'description': '',
                    'each_amount': Decimal('10.00'),
                    'id': '',
                    'quantity': Decimal('1'),
                    'type': 'item',
                }],
                'created_datetime': datetime(2011, 1, 10, 23, 57, 58, tzinfo=tzutc()),
                'id': 'a1f7faaa-6e65-102e-b098-40402145ee8b',
                'number': '1',
                'paid_transaction_id': '',
                'type': 'subscription',
                'vat_rate': '',
            }],
            'items': [{
                'code': 'MONTHLY_ITEM',
                'created_datetime': datetime(2011, 1, 10, 23, 57, 58, tzinfo=tzutc()),
                'id': 'd19b4970-6e5a-102e-b098-40402145ee8b',
                'modified_datetime': datetime(2011, 1, 10, 23, 57, 58, tzinfo=tzutc()),
                'name': 'Monthly Item',
                'quantity': Decimal('3'),
            }, {
                'code': 'ONCE_ITEM',
                'created_datetime': datetime(2011, 1, 10, 23, 57, 58, tzinfo=tzutc()),
                'id': 'd19ef2f0-6e5a-102e-b098-40402145ee8b',
                'modified_datetime': datetime(2011, 1, 10, 23, 57, 58, tzinfo=tzutc()),
                'name': 'Once Item',
                'quantity': Decimal('1'),
            }],
            'plans': [{
                'billing_frequency': 'monthly',
                'billing_frequency_per': 'month',
                'billing_frequency_quantity': 1,
                'billing_frequency_unit': 'months',
                'code': 'TRACKED_MONTHLY',
                'created_datetime': datetime(2011, 1, 10, 22, 40, 34, tzinfo=tzutc()),
                'description': '',
                'id': 'd19974a6-6e5a-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': True,
                    'name': 'Monthly Item',
                    'overage_amount': Decimal('10.00'),
                    'quantity_included': Decimal('2'),
                }, {
                    '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('10.00'),
                    'quantity_included': Decimal('0'),
                }],
                'name': 'Tracked Monthly',
                'recurring_charge_amount': Decimal('10.00'),
                'recurring_charge_code': 'TRACKED_MONTHLY_RECURRING',
                'setup_charge_amount': Decimal('0.00'),
                'setup_charge_code': '',
                'trial_days': 0,
            }],
            'redirect_url': None,
        }],
        '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_customers_parser_with_items/original