def test_report_error_should_report_failure_when_no_component_present(self): mock_line_fun = Mock() failure = lambda: None failure.value = lambda: None failure.getBriefTraceback = lambda: '' failure.getErrorMessage = lambda: 'Something has gone wrong' report_error(failure, line_fun=mock_line_fun) mock_line_fun.assert_called_with('Something has gone wrong')
def test_report_error_should_report_failure_when_no_component_present( self): mock_line_fun = Mock() failure = lambda: None failure.value = lambda: None failure.getBriefTraceback = lambda: 'This is the short traceback' failure.getTraceback = lambda: 'This is the full traceback' failure.getErrorMessage = lambda: 'Something has gone wrong' report_error(failure, line_fun=mock_line_fun) mock_line_fun.assert_called_with('Something has gone wrong')
def test_report_error_should_report_command_and_component(self): mock_line_fun = Mock() failure = lambda: None failure.getErrorMessage = lambda: 'You cannot stop the internet!' failure.value = lambda: None failure.value.orig_protocol = lambda: None failure.value.orig_protocol.cmd = 'stop' failure.value.component = 'internet' report_error(failure, line_fun=mock_line_fun) mock_line_fun.assert_called_with('stop@internet: You cannot stop the internet!')
def test_report_error_should_report_command_and_component(self): mock_line_fun = Mock() failure = lambda: None failure.getErrorMessage = lambda: 'You cannot stop the internet!' failure.value = lambda: None failure.value.orig_protocol = lambda: None failure.value.orig_protocol.cmd = 'stop' failure.value.component = 'internet' report_error(failure, line_fun=mock_line_fun) mock_line_fun.assert_called_with( 'stop@internet: You cannot stop the internet!')