def test_topic_tracker_needs_update(database, user, topic):
 forumsread = ForumsRead.query.filter((ForumsRead.user_id == user.id), (ForumsRead.forum_id == topic.forum_id)).first()
 topicsread = TopicsRead.query.filter((TopicsRead.user_id == user.id), (TopicsRead.topic_id == topic.id)).first()
 with current_app.test_request_context():
  assert topic.tracker_needs_update(forumsread, topicsread)
  topicsread = TopicsRead()
  topicsread.user_id = user.id
  topicsread.topic_id = topic.id
  topicsread.forum_id = topic.forum_id
  topicsread.last_read = datetime.utcnow()
  topicsread.save()
  forumsread = ForumsRead()
  forumsread.user_id = user.id
  forumsread.forum_id = topic.forum_id
  forumsread.last_read = datetime.utcnow()
  forumsread.save()
  assert (not topic.tracker_needs_update(forumsread, topicsread))
  post = Post(content='Test Content')
  post.save(topic=topic, user=user)
  assert topic.tracker_needs_update(forumsread, topicsread)

def test_topic_tracker_needs_update ( database , user , topic ) : forumsread = ForumsRead . query . filter ( ( ForumsRead . user_id == user . id ) , ( ForumsRead . forum_id == topic . forum_id ) ) . first ( ) topicsread = TopicsRead . query . filter ( ( TopicsRead . user_id == user . id ) , ( TopicsRead . topic_id == topic . id ) ) . first ( ) with current_app . test_request_context ( ) : assert topic . tracker_needs_update ( forumsread , topicsread ) topicsread = TopicsRead ( ) topicsread . user_id = user . id topicsread . topic_id = topic . id topicsread . forum_id = topic . forum_id topicsread . last_read = datetime . utcnow ( ) topicsread . save ( ) forumsread = ForumsRead ( ) forumsread . user_id = user . id forumsread . forum_id = topic . forum_id forumsread . last_read = datetime . utcnow ( ) forumsread . save ( ) assert ( not topic . tracker_needs_update ( forumsread , topicsread ) ) post = Post ( content = 'Test Content' ) post . save ( topic = topic , user = user ) assert topic . tracker_needs_update ( forumsread , topicsread )
tests if the topicsread tracker needs an update if a new post has been submitted .