Example #1
0
    def test_remove_old_infos(self):
        read_info_1 = ThreadReadInfoPrototype.read_thread(self.thread, self.account)
        read_info_2 = ThreadReadInfoPrototype.read_thread(self.thread, self.account_2)

        removed_time = datetime.datetime.now() - datetime.timedelta(seconds=forum_settings.UNREAD_STATE_EXPIRE_TIME)
        ThreadReadInfoPrototype._model_class.objects.filter(id=read_info_2.id).update(read_at=removed_time)

        self.assertEqual(ThreadReadInfoPrototype._db_count(), 2)
        ThreadReadInfoPrototype.remove_old_infos()
        self.assertEqual(ThreadReadInfoPrototype._db_count(), 1)
        self.assertEqual(ThreadReadInfoPrototype._db_get_object(0).id, read_info_1.id)
Example #2
0
    def test_remove_old_infos(self):
        read_info_1 = ThreadReadInfoPrototype.read_thread(self.thread, self.account)
        read_info_2 = ThreadReadInfoPrototype.read_thread(self.thread, self.account_2)

        removed_time = datetime.datetime.now() - datetime.timedelta(seconds=forum_settings.UNREAD_STATE_EXPIRE_TIME)
        ThreadReadInfoPrototype._model_class.objects.filter(id=read_info_2.id).update(read_at=removed_time)

        self.assertEqual(ThreadReadInfoPrototype._db_count(), 2)
        ThreadReadInfoPrototype.remove_old_infos()
        self.assertEqual(ThreadReadInfoPrototype._db_count(), 1)
        self.assertEqual(ThreadReadInfoPrototype._db_get_object(0).id, read_info_1.id)
Example #3
0
    def test_create_post_success(self):

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

        response = self.client.post(url('forum:threads:create-post', self.thread3.id), {'text': 'thread3-test-post'})

        post = PostPrototype._db_get_object(4)

        self.check_ajax_ok(response, data={'next_url': url('forum:threads:show', self.thread3.id) + ('?page=1#m%d' % post.id)})

        self.assertEqual(Post.objects.all().count(), 5)

        self.assertEqual(ThreadReadInfoPrototype._db_count(), 1)
        self.assertEqual(ThreadReadInfoPrototype._db_get_object(0).thread_id, self.thread3.id)
Example #4
0
    def test_create_post_success(self):

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

        response = self.client.post(url('forum:threads:create-post', self.thread3.id), {'text': 'thread3-test-post'})

        post = PostPrototype._db_get_object(4)

        self.check_ajax_ok(response, data={'next_url': url('forum:threads:show', self.thread3.id) + ('?page=1#m%d' % post.id)})

        self.assertEqual(Post.objects.all().count(), 5)

        self.assertEqual(ThreadReadInfoPrototype._db_count(), 1)
        self.assertEqual(ThreadReadInfoPrototype._db_get_object(0).thread_id, self.thread3.id)