def test_remove_old_infos(self): read_info_1 = SubCategoryReadInfoPrototype.read_subcategory(self.subcategory, self.account) read_info_2 = SubCategoryReadInfoPrototype.read_subcategory(self.subcategory, self.account_2) removed_time = datetime.datetime.now() - datetime.timedelta(seconds=forum_settings.UNREAD_STATE_EXPIRE_TIME) SubCategoryReadInfoPrototype._model_class.objects.filter(id=read_info_2.id).update(read_at=removed_time) self.assertEqual(SubCategoryReadInfoPrototype._db_count(), 2) SubCategoryReadInfoPrototype.remove_old_infos() self.assertEqual(SubCategoryReadInfoPrototype._db_count(), 1) self.assertEqual(SubCategoryReadInfoPrototype._db_get_object(0).id, read_info_1.id)
def handle(self, *args, **options): from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype from the_tale.forum.prototypes import SubCategoryReadInfoPrototype, ThreadReadInfoPrototype from the_tale.post_service.prototypes import MessagePrototype PostponedTaskPrototype.remove_old_tasks() ThreadReadInfoPrototype.remove_old_infos() SubCategoryReadInfoPrototype.remove_old_infos() MessagePrototype.remove_old_messages()