本文整理汇总了Python中the_tale.accounts.prototypes.AccountPrototype.send_premium_expired_notifications方法的典型用法代码示例。如果您正苦于以下问题:Python AccountPrototype.send_premium_expired_notifications方法的具体用法?Python AccountPrototype.send_premium_expired_notifications怎么用?Python AccountPrototype.send_premium_expired_notifications使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类the_tale.accounts.prototypes.AccountPrototype
的用法示例。
在下文中一共展示了AccountPrototype.send_premium_expired_notifications方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_send_premium_expired_notifications
# 需要导入模块: from the_tale.accounts.prototypes import AccountPrototype [as 别名]
# 或者: from the_tale.accounts.prototypes.AccountPrototype import send_premium_expired_notifications [as 别名]
def test_send_premium_expired_notifications(self):
self.assertEqual(PersonalMessagePrototype._db_count(), 0)
register_user("test_user_2", "[email protected]", "111111")
register_user("test_user_3", "[email protected]", "111111")
register_user("test_user_4", "[email protected]", "111111")
account_1 = self.account
account_2 = AccountPrototype.get_by_nick("test_user_2")
account_3 = AccountPrototype.get_by_nick("test_user_3")
account_4 = AccountPrototype.get_by_nick("test_user_4")
account_1.prolong_premium(accounts_settings.PREMIUM_EXPIRED_NOTIFICATION_IN.days - 1)
account_1.save()
account_3.prolong_premium(accounts_settings.PREMIUM_EXPIRED_NOTIFICATION_IN.days - 1)
account_3.save()
account_4.prolong_premium(accounts_settings.PREMIUM_EXPIRED_NOTIFICATION_IN.days + 1)
account_4.save()
zero_time = datetime.datetime.fromtimestamp(0)
self.assertEqual(account_1._model.premium_expired_notification_send_at, zero_time)
self.assertEqual(account_2._model.premium_expired_notification_send_at, zero_time)
self.assertEqual(account_3._model.premium_expired_notification_send_at, zero_time)
self.assertEqual(account_4._model.premium_expired_notification_send_at, zero_time)
AccountPrototype.send_premium_expired_notifications()
account_1.reload()
account_2.reload()
account_3.reload()
account_4.reload()
self.assertNotEqual(account_1._model.premium_expired_notification_send_at, zero_time)
self.assertEqual(account_2._model.premium_expired_notification_send_at, zero_time)
self.assertNotEqual(account_3._model.premium_expired_notification_send_at, zero_time)
self.assertEqual(account_4._model.premium_expired_notification_send_at, zero_time)
current_time = datetime.datetime.now()
self.assertTrue(
current_time - datetime.timedelta(seconds=60)
< account_1._model.premium_expired_notification_send_at
< current_time
)
self.assertTrue(
current_time - datetime.timedelta(seconds=60)
< account_3._model.premium_expired_notification_send_at
< current_time
)
self.assertEqual(PersonalMessagePrototype._db_count(), 2)
示例2: test_send_premium_expired_notifications
# 需要导入模块: from the_tale.accounts.prototypes import AccountPrototype [as 别名]
# 或者: from the_tale.accounts.prototypes.AccountPrototype import send_premium_expired_notifications [as 别名]
def test_send_premium_expired_notifications(self):
self.assertEqual(PersonalMessagePrototype._db_count(), 0)
account_1 = self.account
account_2 = self.accounts_factory.create_account()
account_3 = self.accounts_factory.create_account()
account_4 = self.accounts_factory.create_account()
account_1.prolong_premium(accounts_settings.PREMIUM_EXPIRED_NOTIFICATION_IN.days-1)
account_1.save()
account_3.prolong_premium(accounts_settings.PREMIUM_EXPIRED_NOTIFICATION_IN.days-1)
account_3.save()
account_4.prolong_premium(accounts_settings.PREMIUM_EXPIRED_NOTIFICATION_IN.days+1)
account_4.save()
zero_time = datetime.datetime.fromtimestamp(0)
self.assertEqual(account_1._model.premium_expired_notification_send_at, zero_time)
self.assertEqual(account_2._model.premium_expired_notification_send_at, zero_time)
self.assertEqual(account_3._model.premium_expired_notification_send_at, zero_time)
self.assertEqual(account_4._model.premium_expired_notification_send_at, zero_time)
AccountPrototype.send_premium_expired_notifications()
account_1.reload()
account_2.reload()
account_3.reload()
account_4.reload()
self.assertNotEqual(account_1._model.premium_expired_notification_send_at, zero_time)
self.assertEqual(account_2._model.premium_expired_notification_send_at, zero_time)
self.assertNotEqual(account_3._model.premium_expired_notification_send_at, zero_time)
self.assertEqual(account_4._model.premium_expired_notification_send_at, zero_time)
current_time = datetime.datetime.now()
self.assertTrue(current_time-datetime.timedelta(seconds=60) < account_1._model.premium_expired_notification_send_at < current_time)
self.assertTrue(current_time-datetime.timedelta(seconds=60) < account_3._model.premium_expired_notification_send_at < current_time)
self.assertEqual(PersonalMessagePrototype._db_count(), 2)
示例3: run_send_premium_expired_notifications
# 需要导入模块: from the_tale.accounts.prototypes import AccountPrototype [as 别名]
# 或者: from the_tale.accounts.prototypes.AccountPrototype import send_premium_expired_notifications [as 别名]
def run_send_premium_expired_notifications(self):
AccountPrototype.send_premium_expired_notifications()