예제 #1
0
    def test_create_plan(self, post_method):
        api = self.make_one('MOCK_API_KEY', endpoint='http://localhost')
        company = Company(api, dict(guid='MOCK_COMPANY_GUID'))
        mock_plan_data = dict(guid='MOCK_PLAN_GUID')
        mock_response = mock.Mock(
            json=lambda: mock_plan_data,
            status_code=200,
        )
        post_method.return_value = mock_response

        plan = company.create_plan(
            plan_type=Plan.TYPE_DEBIT,
            frequency=Plan.FREQ_DAILY,
            amount='5566',
            interval=123,
        )

        self.assertEqual(plan.guid, 'MOCK_PLAN_GUID')
        post_method.assert_called_once_with(
            'http://localhost/v1/plans', 
            data=dict(
                plan_type=Plan.TYPE_DEBIT,
                frequency=Plan.FREQ_DAILY,
                amount='5566',
                interval=123,
            ),
            auth=('MOCK_API_KEY', ''),
        )
예제 #2
0
    def test_create_customer(self, post_method):
        api = self.make_one('MOCK_API_KEY', endpoint='http://localhost')
        company = Company(api, dict(guid='MOCK_COMPANY_GUID'))
        mock_customer_data = dict(guid='CUMOCK_CUSTOMER')
        mock_response = mock.Mock(
            json=lambda: mock_customer_data, 
            status_code=200,
        )
        post_method.return_value = mock_response

        customer = company.create_customer(
            processor_uri='MOCK_BALANCED_CUSTOMER_URI',
        )

        self.assertEqual(customer.guid, 'CUMOCK_CUSTOMER')
        post_method.assert_called_once_with(
            'http://localhost/v1/customers', 
            data=dict(processor_uri='MOCK_BALANCED_CUSTOMER_URI'),
            auth=('MOCK_API_KEY', '')
        )