Esempio n. 1
0
 def test_unexpected_result(self):
     cmd = MCommand(result="foobar")
     with raises(
             ValueError,
             message='expected "ok" or "error" result, but received: foobar'
     ):
         cmd.execute()
Esempio n. 2
0
 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")
Esempio n. 3
0
 def test_blank_result_with_quit(self):
     cmd = MCommand(result="", cmdstr=b"Quit")
     # running without exception is sufficient for this test
     cmd.execute()
Esempio n. 4
0
 def test_blank_result(self):
     cmd = MCommand(result="")
     with raises(ValueError,
                 message='expected "ok" or "error" result, but received: '):
         cmd.execute()
Esempio n. 5
0
 def test_error_response_no_data(self):
     cmd = MCommand(result="error")
     with raises(CommandError, message="[no error message]"):
         cmd.execute()
Esempio n. 6
0
 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"]
Esempio n. 7
0
 def test_data(self):
     data = "data: foo\n"
     data += "data: bar\n"
     cmd = MCommand(data)
     cmd.execute()
     assert cmd.data == [b"foo", b"bar"]
Esempio n. 8
0
 def test_stdin(self, m_write):
     cmd = MCommand()
     cmd.execute()
     cmd.app.write.assert_called_once_with(b"testcmd\n")