当前位置: 首页>>代码示例>>Python>>正文


Python AccountPrototype.send_premium_expired_notifications方法代码示例

本文整理汇总了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)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:56,代码来源:test_account_prototype.py

示例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)
开发者ID:,项目名称:,代码行数:44,代码来源:

示例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()
开发者ID:Alkalit,项目名称:the-tale,代码行数:4,代码来源:accounts_manager.py


注:本文中的the_tale.accounts.prototypes.AccountPrototype.send_premium_expired_notifications方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。