def test_upcoming_invoice( self, product_retrieve_mock, invoice_upcoming_mock, subscription_retrieve_mock, plan_retrieve_mock, ): invoice = UpcomingInvoice.upcoming() self.assertIsNotNone(invoice) self.assertIsNone(invoice.id) self.assertIsNone(invoice.save()) self.assertEqual(invoice.get_stripe_dashboard_url(), "") subscription_retrieve_mock.assert_called_once_with( api_key=ANY, expand=ANY, id=FAKE_SUBSCRIPTION["id"]) plan_retrieve_mock.assert_not_called() items = invoice.invoiceitems.all() self.assertEqual(1, len(items)) self.assertEqual(FAKE_SUBSCRIPTION["id"], items[0].id) # delete/update should do nothing self.assertEqual(invoice.invoiceitems.update(), 0) self.assertEqual(invoice.invoiceitems.delete(), 0) self.assertIsNotNone(invoice.plan) self.assertEqual(FAKE_PLAN["id"], invoice.plan.id) invoice._invoiceitems = [] items = invoice.invoiceitems.all() self.assertEqual(0, len(items)) self.assertIsNotNone(invoice.plan)
def test_upcoming_invoice(self, invoice_upcoming_mock, subscription_retrieve_mock, plan_retrieve_mock): invoice = UpcomingInvoice.upcoming() self.assertIsNotNone(invoice) self.assertIsNone(invoice.stripe_id) self.assertIsNone(invoice.save()) self.assertEqual(invoice.get_stripe_dashboard_url(), "") subscription_retrieve_mock.assert_called_once_with(api_key=ANY, expand=ANY, id=FAKE_SUBSCRIPTION["id"]) plan_retrieve_mock.assert_not_called() items = invoice.invoiceitems.all() self.assertEqual(1, len(items)) self.assertEqual(FAKE_SUBSCRIPTION["id"], items[0].stripe_id) # delete/update should do nothing self.assertEqual(invoice.invoiceitems.update(), 0) self.assertEqual(invoice.invoiceitems.delete(), 0) self.assertIsNotNone(invoice.plan) self.assertEqual(FAKE_PLAN["id"], invoice.plan.stripe_id) invoice._invoiceitems = [] items = invoice.invoiceitems.all() self.assertEqual(0, len(items)) self.assertIsNotNone(invoice.plan)
def test_upcoming_invoice( self, product_retrieve_mock, invoice_upcoming_mock, subscription_retrieve_mock, plan_retrieve_mock, invoice_retrieve_mock, payment_intent_retrieve_mock, paymentmethod_card_retrieve_mock, charge_retrieve_mock, balance_transaction_retrieve_mock, ): # create invoice for latest_invoice in subscription to work. Invoice.sync_from_stripe_data(deepcopy(FAKE_INVOICE)) invoice = UpcomingInvoice.upcoming() self.assertIsNotNone(invoice) self.assertIsNone(invoice.id) self.assertIsNone(invoice.save()) self.assertEqual(invoice.get_stripe_dashboard_url(), "") invoice.id = "foo" self.assertIsNone(invoice.id) subscription_retrieve_mock.assert_called_once_with( api_key=ANY, expand=ANY, id=FAKE_SUBSCRIPTION["id"], stripe_account=None) plan_retrieve_mock.assert_not_called() items = invoice.invoiceitems.all() self.assertEqual(1, len(items)) self.assertEqual(FAKE_SUBSCRIPTION["id"], items[0].id) # delete/update should do nothing self.assertEqual(invoice.invoiceitems.update(), 0) self.assertEqual(invoice.invoiceitems.delete(), 0) self.assertIsNotNone(invoice.plan) self.assertEqual(FAKE_PLAN["id"], invoice.plan.id) invoice._invoiceitems = [] items = invoice.invoiceitems.all() self.assertEqual(0, len(items)) self.assertIsNotNone(invoice.plan) self.assertEqual(invoice.default_tax_rates.count(), 1) self.assertEqual(invoice.default_tax_rates.first().id, FAKE_TAX_RATE_EXAMPLE_1_VAT["id"]) self.assertEqual(invoice.total_tax_amounts.count(), 1) first_tax_amount = invoice.total_tax_amounts.first() self.assertEqual(first_tax_amount.tax_rate.id, FAKE_TAX_RATE_EXAMPLE_1_VAT["id"]) self.assertEqual(first_tax_amount.inclusive, FAKE_TAX_RATE_EXAMPLE_1_VAT["inclusive"]) self.assertEqual(first_tax_amount.amount, 261)
def test_upcoming_invoice( self, product_retrieve_mock, invoice_upcoming_mock, subscription_retrieve_mock, plan_retrieve_mock, ): invoice = UpcomingInvoice.upcoming() self.assertIsNotNone(invoice) self.assertIsNone(invoice.id) self.assertIsNone(invoice.save()) self.assertEqual(invoice.get_stripe_dashboard_url(), "") subscription_retrieve_mock.assert_called_once_with( api_key=ANY, expand=ANY, id=FAKE_SUBSCRIPTION["id"], stripe_account=None ) plan_retrieve_mock.assert_not_called() items = invoice.invoiceitems.all() self.assertEqual(1, len(items)) self.assertEqual(FAKE_SUBSCRIPTION["id"], items[0].id) # delete/update should do nothing self.assertEqual(invoice.invoiceitems.update(), 0) self.assertEqual(invoice.invoiceitems.delete(), 0) self.assertIsNotNone(invoice.plan) self.assertEqual(FAKE_PLAN["id"], invoice.plan.id) invoice._invoiceitems = [] items = invoice.invoiceitems.all() self.assertEqual(0, len(items)) self.assertIsNotNone(invoice.plan) self.assertEqual(invoice.default_tax_rates.count(), 1) self.assertEqual( invoice.default_tax_rates.first().id, FAKE_TAX_RATE_EXAMPLE_1_VAT["id"] ) self.assertEqual(invoice.total_tax_amounts.count(), 1) first_tax_amount = invoice.total_tax_amounts.first() self.assertEqual( first_tax_amount.tax_rate.id, FAKE_TAX_RATE_EXAMPLE_1_VAT["id"] ) self.assertEqual( first_tax_amount.inclusive, FAKE_TAX_RATE_EXAMPLE_1_VAT["inclusive"] ) self.assertEqual(first_tax_amount.amount, 261)
def test_upcoming_invoice(self, invoice_upcoming_mock, subscription_retrieve_mock, plan_retrieve_mock): invoice = UpcomingInvoice.upcoming() self.assertIsNotNone(invoice) self.assertIsNone(invoice.stripe_id) self.assertIsNone(invoice.save()) self.assertEquals(invoice.get_stripe_dashboard_url(), "") subscription_retrieve_mock.assert_called_once_with( api_key=ANY, expand=ANY, id=FAKE_SUBSCRIPTION["id"]) plan_retrieve_mock.assert_not_called() items = invoice.invoiceitems.all() self.assertEquals(1, len(items)) self.assertEquals(FAKE_SUBSCRIPTION["id"], items[0].stripe_id) self.assertIsNotNone(invoice.plan) self.assertEquals(FAKE_PLAN["id"], invoice.plan.stripe_id) invoice._invoiceitems = [] items = invoice.invoiceitems.all() self.assertEquals(0, len(items)) self.assertIsNotNone(invoice.plan)