#NEWLINE# def test_actions_failed_no_log_entries( self ) : #NEWLINE# #INDENT# InvoiceFactory . create ( ) #NEWLINE# url = reverse ( 'admin:silver_invoice_changelist' ) #NEWLINE# mock_log_entry = MagicMock ( ) #NEWLINE# mock_log_action = MagicMock ( ) #NEWLINE# mock_log_entry . objects . log_action = mock_log_action #NEWLINE# exceptions = cycle ( [ ValueError , TransitionNotAllowed ] ) #NEWLINE# def _exception_thrower( * args ) : #NEWLINE# #INDENT# raise exceptions . next ( ) #NEWLINE# #UNINDENT# mock_action = MagicMock ( side_effect = _exception_thrower ) #NEWLINE# mock_invoice = MagicMock ( ) #NEWLINE# mock_invoice . issue = mock_action #NEWLINE# mock_invoice . cancel = mock_action #NEWLINE# mock_invoice . pay = mock_action #NEWLINE# mock_invoice . clone_into_draft = mock_action #NEWLINE# mock_invoice . create_invoice = mock_action #NEWLINE# with patch . multiple ( 'silver.admin' , LogEntry = mock_log_entry , Invoice = mock_invoice ) : #NEWLINE# #INDENT# actions = [ 'issue' , 'pay' , 'cancel' , 'clone' ] #NEWLINE# for action in actions : #NEWLINE# #INDENT# self . admin . post ( url , { #NEWLINE# #INDENT# 'action' : action , #NEWLINE# '_selected_action' : [ '1' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert ( not mock_log_action . call_count )