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


Python MessagePrototype._db_count方法代码示例

本文整理汇总了Python中the_tale.accounts.personal_messages.prototypes.MessagePrototype._db_count方法的典型用法代码示例。如果您正苦于以下问题:Python MessagePrototype._db_count方法的具体用法?Python MessagePrototype._db_count怎么用?Python MessagePrototype._db_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在the_tale.accounts.personal_messages.prototypes.MessagePrototype的用法示例。


在下文中一共展示了MessagePrototype._db_count方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_send_premium_expired_notifications

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import _db_count [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_success__ban_total

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import _db_count [as 别名]
    def test_success__ban_total(self):
        self.check_ajax_ok(self.client.post(reverse('accounts:ban', args=[self.account_1.id]), self.form_data(BAN_TYPE.TOTAL)))

        self.account_1.reload()
        self.assertTrue(self.account_1.is_ban_forum)
        self.assertTrue(self.account_1.is_ban_game)
        self.assertEqual(MessagePrototype._db_count(), 1)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:9,代码来源:test_requests_account.py

示例3: check_not_processed

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import _db_count [as 别名]
    def check_not_processed(self, premiums=0):
        self.assertEqual(MessagePrototype._db_count(), 0)
        self.assertEqual(AccountPrototype._db_filter(premium_end_at__gt=datetime.datetime.now()).count(), premiums)

        self.request.reload()
        self.assertTrue(self.request.state.is_WAITING)
        self.assertEqual(self.request.receiver_id, None)
开发者ID:Alkalit,项目名称:the-tale,代码行数:9,代码来源:test_random_premium_request.py

示例4: test_day_started_signal__only_not_premium

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import _db_count [as 别名]
    def test_day_started_signal__only_not_premium(self):
        self.assertEqual(AccountPrototype._db_count(), 1)

        self.account.prolong_premium(days=30)
        self.account.save()

        old_premium_end_at = self.account.premium_end_at

        self.assertEqual(MessagePrototype._db_count(), 0)

        portal_signals.day_started.send(self.__class__)

        self.assertEqual(MessagePrototype._db_count(), 0)

        self.account.reload()
        self.assertEqual(old_premium_end_at, self.account.premium_end_at)
开发者ID:Alkalit,项目名称:the-tale,代码行数:18,代码来源:test_signals.py

示例5: test_form_errors

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import _db_count [as 别名]
    def test_form_errors(self):
        self.check_ajax_error(self.client.post(reverse('accounts:ban', args=[self.account_1.id]), self.form_data(BAN_TYPE.FORUM, description=u'')),
                              'form_errors')

        self.account_1.reload()
        self.assertFalse(self.account_1.is_ban_forum)
        self.assertFalse(self.account_1.is_ban_game)
        self.assertEqual(MessagePrototype._db_count(), 0)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:10,代码来源:test_requests_account.py

示例6: test_day_started_signal

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import _db_count [as 别名]
    def test_day_started_signal(self):
        self.assertFalse(portal_settings.SETTINGS_ACCOUNT_OF_THE_DAY_KEY in settings)

        self.assertEqual(MessagePrototype._db_count(), 0)

        with mock.patch('the_tale.accounts.workers.accounts_manager.Worker.cmd_run_account_method') as cmd_run_account_method:
            portal_signals.day_started.send(self.__class__)

        self.assertEqual(cmd_run_account_method.call_count, 1)
        self.assertEqual(cmd_run_account_method.call_args, mock.call(account_id=self.account.id,
                                                                     method_name='prolong_premium',
                                                                     data={'days': portal_settings.PREMIUM_DAYS_FOR_HERO_OF_THE_DAY}))

        self.assertEqual(int(settings[portal_settings.SETTINGS_ACCOUNT_OF_THE_DAY_KEY]), self.account.id)

        self.assertEqual(MessagePrototype._db_count(), 1)
        message = MessagePrototype._db_get_object(0)
        self.assertEqual(message.sender_id, get_system_user().id)
        self.assertEqual(message.recipient_id, self.account.id)
开发者ID:Alkalit,项目名称:the-tale,代码行数:21,代码来源:test_signals.py

示例7: test_send_premium_expired_notifications

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import _db_count [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,代码来源:

示例8: test_no_rights

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import _db_count [as 别名]
    def test_no_rights(self):
        self.request_logout()
        self.request_login('[email protected]')

        self.check_ajax_error(self.client.post(reverse('accounts:ban', args=[self.account_1.id]), self.form_data(BAN_TYPE.FORUM)),
                              'accounts.no_moderation_rights')

        self.account_1.reload()
        self.assertFalse(self.account_1.is_ban_forum)
        self.assertFalse(self.account_1.is_ban_game)
        self.assertEqual(MessagePrototype._db_count(), 0)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:13,代码来源:test_requests_account.py

示例9: test_process__has_active_accounts

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import _db_count [as 别名]
    def test_process__has_active_accounts(self):
        AccountPrototype._db_all().update(active_end_at=datetime.datetime.now() + datetime.timedelta(days=1))

        self.request.process()

        self.assertEqual(MessagePrototype._db_count(), 1)

        message = MessagePrototype._db_get_object(0)
        self.assertEqual(message.recipient_id, self.account_2.id)
        self.assertEqual(message.sender_id, get_system_user().id)

        self.assertEqual(list(AccountPrototype._db_filter(premium_end_at__gt=datetime.datetime.now()).values_list('id', flat=True)), [self.account_2.id])

        self.request.reload()
        self.assertTrue(self.request.state.is_PROCESSED)
        self.assertEqual(self.request.receiver_id, self.account_2.id)
开发者ID:Alkalit,项目名称:the-tale,代码行数:18,代码来源:test_random_premium_request.py

示例10: test_notify_about_premium_expiration

# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import _db_count [as 别名]
 def test_notify_about_premium_expiration(self):
     self.assertEqual(PersonalMessagePrototype._db_count(), 0)
     self.account.notify_about_premium_expiration()
     self.assertEqual(PersonalMessagePrototype._db_count(), 1)
开发者ID:Jazzis18,项目名称:the-tale,代码行数:6,代码来源:test_account_prototype.py


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