def test___str__(self, customer_retrieve_mock): schedule = SubscriptionSchedule.sync_from_stripe_data( deepcopy(FAKE_SUBSCRIPTION_SCHEDULE)) self.assertEqual(f"<id={FAKE_SUBSCRIPTION_SCHEDULE['id']}>", str(schedule)) self.assert_fks(schedule, expected_blank_fks=self.default_expected_blank_fks)
def test_sync_from_stripe_data(self, customer_retrieve_mock): canceled_schedule_fake = deepcopy(FAKE_SUBSCRIPTION_SCHEDULE) canceled_schedule_fake["canceled_at"] = 1624553655 canceled_schedule_fake["status"] = SubscriptionScheduleStatus.canceled schedule = SubscriptionSchedule.sync_from_stripe_data(canceled_schedule_fake) self.assert_fks(schedule, expected_blank_fks=self.default_expected_blank_fks) self.assertEqual(datetime_to_unix(schedule.canceled_at), 1624553655)
def test_update( self, customer_retrieve_mock, product_retrieve_mock, plan_retrieve_mock, ): schedule = SubscriptionSchedule.sync_from_stripe_data( deepcopy(FAKE_SUBSCRIPTION_SCHEDULE)) with patch.object( stripe.SubscriptionSchedule, "modify", return_value=FAKE_SUBSCRIPTION_SCHEDULE, ) as patched__api_update: schedule.update() patched__api_update.assert_called_once_with( FAKE_SUBSCRIPTION_SCHEDULE["id"], api_key=djstripe_settings.STRIPE_SECRET_KEY, stripe_account=schedule.djstripe_owner_account.id, )