def test_topic_save(forum, user):
 post = Post(content='Test Content')
 topic = Topic(title='Test Title')
 assert (forum.last_post_id is None)
 assert (forum.post_count == 0)
 assert (forum.topic_count == 0)
 topic.save(forum=forum, post=post, user=user)
 assert (topic.title == 'Test Title')
 topic.title = 'Test Edit Title'
 topic.save()
 assert (topic.title == 'Test Edit Title')
 assert (topic.first_post_id == post.id)
 assert (topic.last_post_id == post.id)
 assert (forum.last_post_id == post.id)
 assert (forum.post_count == 1)
 assert (forum.topic_count == 1)

def test_topic_save ( forum , user ) : post = Post ( content = 'Test Content' ) topic = Topic ( title = 'Test Title' ) assert ( forum . last_post_id is None ) assert ( forum . post_count == 0 ) assert ( forum . topic_count == 0 ) topic . save ( forum = forum , post = post , user = user ) assert ( topic . title == 'Test Title' ) topic . title = 'Test Edit Title' topic . save ( ) assert ( topic . title == 'Test Edit Title' ) assert ( topic . first_post_id == post . id ) assert ( topic . last_post_id == post . id ) assert ( forum . last_post_id == post . id ) assert ( forum . post_count == 1 ) assert ( forum . topic_count == 1 )
test the save topic method with creating and editing a topic .