def test_post_delete(topic):
 post_middle = Post(content='Test Content Middle')
 post_middle.save(topic=topic, user=topic.user)
 post_last = Post(content='Test Content Last')
 post_last.save(topic=topic, user=topic.user)
 assert (topic.post_count == 3)
 assert (topic.forum.post_count == 3)
 assert (topic.user.post_count == 3)
 post_middle.delete()
 assert (topic.last_post == post_last)
 assert (topic.forum.last_post == post_last)
 post_last.delete()
 assert (topic.post_count == 1)
 assert (topic.forum.post_count == 1)
 assert (topic.user.post_count == 1)
 assert (topic.first_post_id == topic.last_post_id)
 assert (topic.forum.last_post_id == topic.last_post_id)

def test_post_delete ( topic ) : post_middle = Post ( content = 'Test Content Middle' ) post_middle . save ( topic = topic , user = topic . user ) post_last = Post ( content = 'Test Content Last' ) post_last . save ( topic = topic , user = topic . user ) assert ( topic . post_count == 3 ) assert ( topic . forum . post_count == 3 ) assert ( topic . user . post_count == 3 ) post_middle . delete ( ) assert ( topic . last_post == post_last ) assert ( topic . forum . last_post == post_last ) post_last . delete ( ) assert ( topic . post_count == 1 ) assert ( topic . forum . post_count == 1 ) assert ( topic . user . post_count == 1 ) assert ( topic . first_post_id == topic . last_post_id ) assert ( topic . forum . last_post_id == topic . last_post_id )
tests the delete post method with three different post types .