Example #1
0
    def test_deleted(self):
        # Nothing exists before the test starts
        eq_(ThreadMappingType.search().count(), 0)

        # Creating a new Thread does create a new document in the index.
        new_thread = ThreadFactory()
        self.refresh()
        eq_(ThreadMappingType.search().count(), 1)

        # Deleting the thread deletes the document in the index.
        new_thread.delete()
        self.refresh()
        eq_(ThreadMappingType.search().count(), 0)
Example #2
0
    def test_deleted(self):
        # Nothing exists before the test starts
        eq_(ThreadMappingType.search().count(), 0)

        # Creating a new Thread does create a new document in the index.
        new_thread = ThreadFactory()
        self.refresh()
        eq_(ThreadMappingType.search().count(), 1)

        # Deleting the thread deletes the document in the index.
        new_thread.delete()
        self.refresh()
        eq_(ThreadMappingType.search().count(), 0)
Example #3
0
    def test_delete_thread_with_last_forum_post(self):
        # Deleting the thread with a forum's last post should update
        # the last_post field on the forum
        t = ThreadFactory()
        f = t.forum
        last_post = f.last_post

        # add a new thread and post, verify last_post updated
        t = ThreadFactory(title='test', forum=f, posts=[])
        p = PostFactory(thread=t, content='test', author=t.creator)
        f = Forum.objects.get(id=f.id)
        eq_(f.last_post.id, p.id)

        # delete the post, verify last_post updated
        t.delete()
        f = Forum.objects.get(id=f.id)
        eq_(f.last_post.id, last_post.id)
        eq_(Thread.objects.filter(pk=t.id).count(), 0)
Example #4
0
    def test_delete_thread_with_last_forum_post(self):
        # Deleting the thread with a forum's last post should update
        # the last_post field on the forum
        t = ThreadFactory()
        f = t.forum
        last_post = f.last_post

        # add a new thread and post, verify last_post updated
        t = ThreadFactory(title='test', forum=f, posts=[])
        p = PostFactory(thread=t, content='test', author=t.creator)
        f = Forum.objects.get(id=f.id)
        eq_(f.last_post.id, p.id)

        # delete the post, verify last_post updated
        t.delete()
        f = Forum.objects.get(id=f.id)
        eq_(f.last_post.id, last_post.id)
        eq_(Thread.objects.filter(pk=t.id).count(), 0)
Example #5
0
 def test_delete_last_and_only_post_in_thread(self):
     """Deleting the only post in a thread should delete the thread"""
     t = ThreadFactory()
     eq_(1, t.post_set.count())
     t.delete()
     eq_(0, Thread.objects.filter(pk=t.id).count())
Example #6
0
 def test_delete_removes_watches(self):
     t = ThreadFactory()
     NewPostEvent.notify('*****@*****.**', t)
     assert NewPostEvent.is_notifying('*****@*****.**', t)
     t.delete()
     assert not NewPostEvent.is_notifying('*****@*****.**', t)
Example #7
0
 def test_delete_last_and_only_post_in_thread(self):
     """Deleting the only post in a thread should delete the thread"""
     t = ThreadFactory()
     eq_(1, t.post_set.count())
     t.delete()
     eq_(0, Thread.objects.filter(pk=t.id).count())
Example #8
0
 def test_delete_removes_watches(self):
     t = ThreadFactory()
     NewPostEvent.notify('*****@*****.**', t)
     assert NewPostEvent.is_notifying('*****@*****.**', t)
     t.delete()
     assert not NewPostEvent.is_notifying('*****@*****.**', t)