async def test_retrieve_invoice_items(self): customer = aiostripe.Customer(id='cus_get_invoice_items') await customer.invoice_items() self.requestor_mock.request.assert_called_with('get', '/v1/invoiceitems', {'customer': 'cus_get_invoice_items'})
async def test_invoice_create(self): customer = aiostripe.Customer(id='cus_invoice') await aiostripe.Invoice.create(customer=customer.id) self.requestor_mock.request.assert_called_with('post', '/v1/invoices', { 'customer': 'cus_invoice', }, None)
async def test_add_invoice_item(self): customer = aiostripe.Customer(id='cus_invoice_items') await customer.add_invoice_item(**DUMMY_INVOICE_ITEM) expected = DUMMY_INVOICE_ITEM.copy() expected['customer'] = 'cus_invoice_items' self.requestor_mock.request.assert_called_with('post', '/v1/invoiceitems', expected, None)
async def test_unset_description(self): customer = aiostripe.Customer(id='cus_unset_desc') customer.description = 'Hey' await customer.save(idempotency_key='foo') self.requestor_mock.request.assert_called_with( 'post', '/v1/customers/cus_unset_desc', { 'description': 'Hey', }, {'Idempotency-Key': 'foo'})
async def test_del_coupon(self): customer = aiostripe.Customer(id='cus_unset_desc') customer.description = 'bar' customer.coupon = 'foo' del customer.coupon await customer.save() self.requestor_mock.request.assert_called_with( 'post', '/v1/customers/cus_unset_desc', {'description': 'bar'}, None)
def test_cannot_set_empty_string(self): customer = aiostripe.Customer() self.assertRaises(ValueError, setattr, customer, 'description', '')
async def test_missing_id(self): customer = aiostripe.Customer() await self.assertRaisesAsync(aiostripe.error.InvalidRequestError, customer.refresh)