def test_unexpected_result(self): cmd = MCommand(result="foobar") with raises( ValueError, message='expected "ok" or "error" result, but received: foobar' ): cmd.execute()
def test_error_response(self): data = "data: some kind \n" data += "data: of error\n" cmd = MCommand(data, result="error") with raises(CommandError): cmd.execute() fail("some kind of error")
def test_blank_result_with_quit(self): cmd = MCommand(result="", cmdstr=b"Quit") # running without exception is sufficient for this test cmd.execute()
def test_blank_result(self): cmd = MCommand(result="") with raises(ValueError, message='expected "ok" or "error" result, but received: '): cmd.execute()
def test_error_response_no_data(self): cmd = MCommand(result="error") with raises(CommandError, message="[no error message]"): cmd.execute()
def test_data_windows_line_endings(self): data = "data: foo\r\n" data += "data: bar\r\n" cmd = MCommand(data) cmd.execute() assert cmd.data == [b"foo", b"bar"]
def test_data(self): data = "data: foo\n" data += "data: bar\n" cmd = MCommand(data) cmd.execute() assert cmd.data == [b"foo", b"bar"]
def test_stdin(self, m_write): cmd = MCommand() cmd.execute() cmd.app.write.assert_called_once_with(b"testcmd\n")