Beispiel #1
0
    def get_all_plans(self):
        response = self.client.make_request(path='plans/get')
        plans_parser = PlansParser()
        plans_data = plans_parser.parse_xml(response.content)
        plans = [PricingPlan(**plan_data) for plan_data in plans_data]

        return plans
Beispiel #2
0
 def get_all_plans(self):
     response = self.client.make_request(path='plans/get')
     plans_parser = PlansParser()
     plans_data = plans_parser.parse_xml(response.content)
     plans = [PricingPlan(**plan_data) for plan_data in plans_data]
     
     return plans
Beispiel #3
0
    def get_plan(self, code):
        response = self.client.make_request(path="plans/get", params={"code": code})
        plans_parser = PlansParser()
        plans_data = plans_parser.parse_xml(response.content)
        plans = [PricingPlan(**plan_data) for plan_data in plans_data]

        return plans[0]
Beispiel #4
0
    def get_plan(self, code):
        response = self.client.make_request(
            path='plans/get',
            params={'code': code},
        )
        plans_parser = PlansParser()
        plans_data = plans_parser.parse_xml(response.content)
        plans = [PricingPlan(**plan_data) for plan_data in plans_data]

        return plans[0]
Beispiel #5
0
    def test_plans_parser(self):
        ''' Test plans parser. '''
        plans_xml = self.load_file('plans.xml')
        parser = PlansParser()

        expected = [
            {
                'billing_frequency': 'monthly',
                'billing_frequency_per': 'month',
                'billing_frequency_quantity': 1,
                'billing_frequency_unit': 'months',
                'code': 'FREE_MONTHLY',
                'created_datetime': datetime(2011, 1, 7, 20, 46, 43,
                                             tzinfo=tzutc()),
                'description': 'A free monthly plan',
                'id': '6b0d13f4-6bef-102e-b098-40402145ee8b',
                'initial_bill_count': 1,
                'initial_bill_count_unit': 'months',
                'is_active': True,
                'is_free': True,
                'items': [],
                'name': 'Free Monthly',
                'recurring_charge_amount': Decimal('0.00'),
                'recurring_charge_code': 'FREE_MONTHLY_RECURRING',
                'setup_charge_amount': Decimal('0.00'),
                'setup_charge_code': '',
                'trial_days': 0},
            {
                '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': [],
                '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}]
        result = parser.parse_xml(plans_xml)
        import pprint
        pp = pprint.PrettyPrinter(indent=4)
        pp.pprint(result)
        self.assertEquals(expected, result)
Beispiel #6
0
    def test_plans_parser_with_items(self):
        plans_xml = self.load_file('plans_with_items.xml')
        parser = PlansParser()

        expected = [   {   'billing_frequency': 'monthly',
            'billing_frequency_per': 'month',
            'billing_frequency_quantity': 1,
            'billing_frequency_unit': 'months',
            'code': 'FREE_MONTHLY',
            'created_datetime': datetime(2011, 1, 7, 20, 46, 43, tzinfo=tzutc()),
            'description': 'A free monthly plan',
            'id': '6b0d13f4-6bef-102e-b098-40402145ee8b',
            'initial_bill_count': 1,
            'initial_bill_count_unit': 'months',
            'is_active': True,
            'is_free': True,
            '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': 'Free Monthly',
            'recurring_charge_amount': Decimal('0.00'),
            'recurring_charge_code': 'FREE_MONTHLY_RECURRING',
            'setup_charge_amount': Decimal('0.00'),
            'setup_charge_code': '',
            'trial_days': 0},
        {   '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},
        {   '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}]
        result = parser.parse_xml(plans_xml)
        import pprint
        pp = pprint.PrettyPrinter(indent=4)
        pp.pprint(result)

        self.assertEquals(expected, result)
Beispiel #7
0
    def test_plans_parser_with_items(self):
        plans_xml = self.load_file('plans_with_items.xml')
        parser = PlansParser()

        expected = [{
            'billing_frequency':
            'monthly',
            'billing_frequency_per':
            'month',
            'billing_frequency_quantity':
            1,
            'billing_frequency_unit':
            'months',
            'code':
            'FREE_MONTHLY',
            'created_datetime':
            datetime(2011, 1, 7, 20, 46, 43, tzinfo=tzutc()),
            'description':
            'A free monthly plan',
            'id':
            '6b0d13f4-6bef-102e-b098-40402145ee8b',
            'initial_bill_count':
            1,
            'initial_bill_count_unit':
            'months',
            'is_active':
            True,
            'is_free':
            True,
            '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':
            'Free Monthly',
            'recurring_charge_amount':
            Decimal('0.00'),
            'recurring_charge_code':
            'FREE_MONTHLY_RECURRING',
            'setup_charge_amount':
            Decimal('0.00'),
            'setup_charge_code':
            '',
            'trial_days':
            0
        }, {
            '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
        }, {
            '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
        }]
        result = parser.parse_xml(plans_xml)
        import pprint
        pp = pprint.PrettyPrinter(indent=4)
        pp.pprint(result)

        self.assertEquals(expected, result)
Beispiel #8
0
    def test_plans_parser(self):
        plans_xml = self.load_file('plans.xml')
        parser = PlansParser()

        expected = [{
            'billing_frequency':
            'monthly',
            'billing_frequency_per':
            'month',
            'billing_frequency_quantity':
            1,
            'billing_frequency_unit':
            'months',
            'code':
            'FREE_MONTHLY',
            'created_datetime':
            datetime(2011, 1, 7, 20, 46, 43, tzinfo=tzutc()),
            'description':
            'A free monthly plan',
            'id':
            '6b0d13f4-6bef-102e-b098-40402145ee8b',
            'initial_bill_count':
            1,
            'initial_bill_count_unit':
            'months',
            'is_active':
            True,
            'is_free':
            True,
            'items': [],
            'name':
            'Free Monthly',
            'recurring_charge_amount':
            Decimal('0.00'),
            'recurring_charge_code':
            'FREE_MONTHLY_RECURRING',
            'setup_charge_amount':
            Decimal('0.00'),
            'setup_charge_code':
            '',
            'trial_days':
            0
        }, {
            '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': [],
            '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
        }]
        result = parser.parse_xml(plans_xml)
        import pprint
        pp = pprint.PrettyPrinter(indent=4)
        pp.pprint(result)
        self.assertEquals(expected, result)