29 lines
1.3 KiB
Python
29 lines
1.3 KiB
Python
"""Same steps as `mplex_flow_test --native`, through tai.py's own NativePlexerController and PlexerFlow.
|
|
|
|
usage: python3 -I mplex_native_oracle.py <repo root> (env TAI_PLEXER_SOCKET / TAI_PLEXER_PANE set)
|
|
"""
|
|
import importlib.util
|
|
import json
|
|
import sys
|
|
import time
|
|
|
|
root = sys.argv[1]
|
|
spec = importlib.util.spec_from_file_location("tai_mod", root + "/tai.py")
|
|
tai = importlib.util.module_from_spec(spec)
|
|
sys.modules["tai_mod"] = tai
|
|
spec.loader.exec_module(tai)
|
|
controller = tai.PlexerControllerFactory.detect()
|
|
status = controller.status()
|
|
print("status-keys %s kind %s" % ("".join(key + "," for key in status), controller.kind))
|
|
print("send", json.dumps(controller.send_keys("echo native-$((20+22))", True)))
|
|
time.sleep(0.6)
|
|
print("read-has-marker", int("native-42" in controller.read_pane(30)))
|
|
app, err = tai.validate_flow_spec({
|
|
"title": "Deploy", "timeout": 30, "screens": [{
|
|
"id": "main", "title": "Where", "body": "Pick.",
|
|
"fields": [{"id": "env", "type": "choice", "label": "Environment", "options": ["staging", "prod"]},
|
|
{"id": "tag", "type": "text", "label": "Tag", "initial": "v1", "show_if": {"env": "prod"}}],
|
|
"actions": [{"id": "go", "label": "Deploy"}, {"id": "back", "label": "Back"}]}]})
|
|
sys.stdout.flush()
|
|
print("outcome", json.dumps(tai.PlexerFlow(app).run(controller)))
|