#NEWLINE# def test_can_view_stats( self ) : #NEWLINE# #INDENT# c = Collection . objects . create ( author = self . user , slug = 'boom' ) #NEWLINE# fake_request = mock . Mock ( ) #NEWLINE# fake_request . user = self . user #NEWLINE# assert c . can_view_stats ( fake_request ) #NEWLINE# fake_request . user = UserProfile . objects . create ( username = 'scrub' , email = 'ez@dee' ) #NEWLINE# assert ( not c . can_view_stats ( fake_request ) ) #NEWLINE# group = Group . objects . create ( name = 'Collections Agency' , rules = 'CollectionStats:View' ) #NEWLINE# del fake_request . user . groups_list #NEWLINE# grouser = GroupUser . objects . create ( user = fake_request . user , group = group ) #NEWLINE# assert c . can_view_stats ( fake_request ) #NEWLINE# grouser . delete ( ) #NEWLINE# del fake_request . user . groups_list #NEWLINE# CollectionUser . objects . create ( collection = c , user = self . user ) #NEWLINE# fake_request . user = self . user #NEWLINE# assert c . can_view_stats ( fake_request )