def test_command_fail(self): response = MockResponse(["line1", "line2"], 1001) request = MockReq(response) cmixer = Commands(mock.MagicMock(), mock.MagicMock(), mock.MagicMock(), mock.MagicMock(), mock.MagicMock()) cmixer._logger = MockLogger() with self.assertRaises(TestStepFail): cmixer._command_fail(request) with self.assertRaises(TestStepFail): request.response.retcode = -5 cmixer._command_fail(request) with self.assertRaises(TestStepFail): request.response.retcode = -2 cmixer._command_fail(request) with self.assertRaises(TestStepFail): request.response.retcode = -3 cmixer._command_fail(request) with self.assertRaises(TestStepFail): request.response.retcode = -4 cmixer._command_fail(request) with self.assertRaises(TestStepTimeout): request.response.timeout = True cmixer._command_fail(request) request.response = None with self.assertRaises(TestStepFail): cmixer._command_fail(request)
def test_command_fail_nameerror(self): cmixer = Commands(mock.MagicMock(), mock.MagicMock(), mock.MagicMock(), mock.MagicMock(), mock.MagicMock()) cmixer._logger = MockLogger() with self.assertRaises(NameError): cmixer._command_fail(None, fail_reason="this_fail")