def test_forum_is_unread(guest, user, forum, topic, forumsread):
 assert (not forum_is_unread(None, None, guest))
 assert forum_is_unread(forum, None, user)
 assert forum_is_unread(forum, forumsread, user)
 topic.update_read(user, topic.forum, forumsread)
 time_read = (datetime.datetime.utcnow() - datetime.timedelta(hours=1))
 forumsread.cleared = time_read
 forumsread.last_read = datetime.datetime.utcnow()
 forumsread.save()
 assert (not forum_is_unread(forum, forumsread, user))
 flaskbb_config['TRACKER_LENGTH'] = 0
 assert (not forum_is_unread(forum, forumsread, user))
 flaskbb_config['TRACKER_LENGTH'] = 1
 forum.last_post_created = (forum.last_post_created - datetime.timedelta(hours=48))
 forum.save()
 assert (not forum_is_unread(forum, forumsread, user))
 topic.delete()
 forum = Forum.query.filter_by(id=forum.id).first()
 flaskbb_config['TRACKER_LENGTH'] = 1
 assert (forum.topic_count == 0)
 assert (not forum_is_unread(forum, None, user))

def test_forum_is_unread ( guest , user , forum , topic , forumsread ) : assert ( not forum_is_unread ( None , None , guest ) ) assert forum_is_unread ( forum , None , user ) assert forum_is_unread ( forum , forumsread , user ) topic . update_read ( user , topic . forum , forumsread ) time_read = ( datetime . datetime . utcnow ( ) - datetime . timedelta ( hours = 1 ) ) forumsread . cleared = time_read forumsread . last_read = datetime . datetime . utcnow ( ) forumsread . save ( ) assert ( not forum_is_unread ( forum , forumsread , user ) ) flaskbb_config [ 'TRACKER_LENGTH' ] = 0 assert ( not forum_is_unread ( forum , forumsread , user ) ) flaskbb_config [ 'TRACKER_LENGTH' ] = 1 forum . last_post_created = ( forum . last_post_created - datetime . timedelta ( hours = 48 ) ) forum . save ( ) assert ( not forum_is_unread ( forum , forumsread , user ) ) topic . delete ( ) forum = Forum . query . filter_by ( id = forum . id ) . first ( ) flaskbb_config [ 'TRACKER_LENGTH' ] = 1 assert ( forum . topic_count == 0 ) assert ( not forum_is_unread ( forum , None , user ) )
test the forum is unread function .