#NEWLINE# def test_verify_active_entry( self ) : #NEWLINE# #INDENT# '\n        A user shouldnt be able to verify a timesheet if it contains\n        an active entry and should be redirect back to the ledger\n        ' #NEWLINE# self . login_as_admin ( ) #NEWLINE# entry1 = factories . Entry ( ** { #NEWLINE# #INDENT# 'user' : self . user , #NEWLINE# 'start_time' : ( self . now - relativedelta ( hours = 5 ) ) , #NEWLINE# 'end_time' : ( self . now - relativedelta ( hours = 4 ) ) , #NEWLINE# 'status' : Entry . UNVERIFIED , #NEWLINE# #UNINDENT# } ) #NEWLINE# entry2 = factories . Entry ( ** { #NEWLINE# #INDENT# 'user' : self . user , #NEWLINE# 'start_time' : ( self . now - relativedelta ( hours = 1 ) ) , #NEWLINE# 'status' : Entry . UNVERIFIED , #NEWLINE# #UNINDENT# } ) #NEWLINE# response = self . client . get ( self . verify_url ( ) , follow = True ) #NEWLINE# self . assertEquals ( response . status_code , 200 ) #NEWLINE# messages = response . context [ 'messages' ] #NEWLINE# msg = 'You cannot verify/approve this timesheet while the user {0} has an active entry. Please have them close any active entries.' . format ( self . user . get_name_or_username ( ) ) #NEWLINE# self . assertEquals ( messages . _loaded_messages [ 0 ] . message , msg ) #NEWLINE# self . assertEquals ( entry1 . status , Entry . UNVERIFIED ) #NEWLINE# self . assertEquals ( entry2 . status , Entry . UNVERIFIED ) #NEWLINE# response = self . client . post ( self . verify_url ( ) , follow = True ) #NEWLINE# self . assertEquals ( response . status_code , 200 ) #NEWLINE# messages = response . context [ 'messages' ] #NEWLINE# self . assertEquals ( messages . _loaded_messages [ 0 ] . message , msg ) #NEWLINE# self . assertEquals ( entry1 . status , Entry . UNVERIFIED ) #NEWLINE# self . assertEquals ( entry2 . status , Entry . UNVERIFIED )