Example #1
0
  def test_sanity(self):
    cin = StringIO.StringIO('echo --ping foo\nsys --quit\n')
    cout = StringIO.StringIO()

    console = hlib.console.Console(None, DummyEngine(), cin, cout)
    console.register_command('echo', EchoCommand)
    console.cmdloop()

    EQ(cout.getvalue(), """console# {
    "pong": "foo",
    "status": "OK"
}
console# {
    "status": "OK"
}
""")
Example #2
0
  def test_missing_arg(self):
    cin = StringIO.StringIO('echo\nsys --quit\n')
    cout = StringIO.StringIO()

    console = hlib.console.Console(None, DummyEngine(), cin, cout)
    console.register_command('echo', EchoCommand)
    console.cmdloop()

    EQ(cin.getvalue(), """echo
sys --quit
""")
    EQ(cout.getvalue(), """console# {
    "message": "argument --ping is required",
    "status": "ERROR"
}
console# {
    "status": "OK"
}
""")