#NEWLINE# def test_can_determine_unread_forums( self ) : #NEWLINE# #INDENT# def get_rendered( forums , user ) : #NEWLINE# #INDENT# request = self . get_request ( ) #NEWLINE# request . user = user #NEWLINE# ForumPermissionMiddleware ( ) . process_request ( request ) #NEWLINE# t = Template ( ( self . loadstatement + '{% get_unread_forums forums request.user as unread_forums %}' ) ) #NEWLINE# c = Context ( { #NEWLINE# #INDENT# 'forums' : forums , #NEWLINE# 'request' : request , #NEWLINE# #UNINDENT# } ) #NEWLINE# rendered = t . render ( c ) #NEWLINE# return ( c , rendered ) #NEWLINE# #UNINDENT# ( context , rendered ) = get_rendered ( Forum . objects . all ( ) , self . u2 ) #NEWLINE# assert ( rendered == '' ) #NEWLINE# assert ( set ( context [ 'unread_forums' ] ) == set ( [ self . top_level_cat , self . forum_1 , self . forum_2 ] ) ) #NEWLINE# ForumReadTrackFactory . create ( forum = self . forum_1 , user = self . u2 ) #NEWLINE# ForumReadTrackFactory . create ( forum = self . forum_2 , user = self . u2 ) #NEWLINE# ( context , rendered ) = get_rendered ( Forum . objects . all ( ) , self . u2 ) #NEWLINE# assert ( rendered == '' ) #NEWLINE# assert ( not len ( context [ 'unread_forums' ] ) ) #NEWLINE# PostFactory . create ( topic = self . forum_2_topic , poster = self . u1 ) #NEWLINE# ( context , rendered ) = get_rendered ( Forum . objects . all ( ) , self . u2 ) #NEWLINE# assert ( rendered == '' ) #NEWLINE# assert ( set ( context [ 'unread_forums' ] ) == set ( [ self . forum_2 , self . top_level_cat ] ) )