AT_BANNER([JSON-RPC - Python3])

AT_SETUP([JSON-RPC request and successful reply - Python3])
AT_KEYWORDS([python jsonrpc])
AT_CHECK([$PYTHON3 $srcdir/test-jsonrpc.py --pidfile --detach --no-chdir listen punix:socket])
on_exit 'kill `cat test-jsonrpc.py.pid`'
AT_CHECK(
  [[$PYTHON3 $srcdir/test-jsonrpc.py request unix:socket echo '[{"a": "b", "x": null}]']], [0],
  [[{"error":null,"id":0,"result":[{"a":"b","x":null}]}
]])
AT_CLEANUP

AT_SETUP([JSON-RPC request and error reply - Python3])
AT_KEYWORDS([python jsonrpc])
AT_CHECK([$PYTHON3 $srcdir/test-jsonrpc.py --pidfile --detach --no-chdir listen punix:socket])
on_exit 'kill `cat test-jsonrpc.py.pid`'
AT_CHECK(
  [[$PYTHON3 $srcdir/test-jsonrpc.py request unix:socket bad-request '[]']], [0],
  [[{"error":{"error":"unknown method"},"id":0,"result":null}
]])
AT_CLEANUP

AT_SETUP([JSON-RPC notification - Python3])
AT_KEYWORDS([python jsonrpc])
AT_CHECK([$PYTHON3 $srcdir/test-jsonrpc.py --pidfile --detach --no-chdir listen punix:socket])
on_exit 'kill `cat test-jsonrpc.py.pid`'
AT_CHECK([test -e test-jsonrpc.py.pid])
AT_CHECK([[$PYTHON3 $srcdir/test-jsonrpc.py notify unix:socket shutdown '[]']])
# Wait for test-jsonrpc to die, based on its pidfile disappearing
OVS_WAIT_WHILE([test -e test-jsonrpc.py.pid])
AT_CLEANUP
