diff --git a/tests/demo_items/command.py b/tests/demo_items/command.py new file mode 100755 index 0000000..d665a34 --- /dev/null +++ b/tests/demo_items/command.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 + +import argparse, json, sys, time + +parser = argparse.ArgumentParser() +parser.add_argument("action") +args = parser.parse_args() + +print("args:", args, file=sys.stderr, flush=True) + +def item(i): + print(json.dumps(i)) + +if args.action == "fetch": + item({ + "id": "item1-only-id", + }) + item({ + "id": "item2-title", + "title": "This item has a title", + }) + item({ + "id": "item3-body", + "title": "This item has a title and body", + "body": "
Hello, intake! This is an item body.
", + }) + item({ + "id": "item4-action", + "title": "This item has an action but no body", + "action": { + "action1": None + }, + }) + item({ + "id": "item5-actions", + "title": "This item has two actions and a body", + "body": "This is body text.
", + "action": { + "action1": None, + "action2": None, + }, + }) + item({ + "id": "item6-footer", + "title": "No body text but all footer fields", + "author": "Authorname", + "time": int(time.time()), + }) + item({ + "id": "item7-footer", + "title": "Body text and all footer fields", + "author": "Authorname", + "time": int(time.time()), + "body": "This is body text.
", + }) + item({ + "id": "item8-link", + "title": "Item with a link", + "link": "#", + }) + +if args.action == "action1": + item = sys.stdin.readline() + item = json.loads(item) + print(json.dumps(item)) + +if args.action == "action2": + item = sys.stdin.readline() + item = json.loads(item) + print(json.dumps(item)) diff --git a/tests/demo_items/intake.json b/tests/demo_items/intake.json new file mode 100644 index 0000000..348fc3d --- /dev/null +++ b/tests/demo_items/intake.json @@ -0,0 +1,22 @@ +{ + "action": { + "fetch": { + "exe": "./command.py", + "args": [ + "fetch" + ] + }, + "action1": { + "exe": "./command.py", + "args": [ + "action1" + ] + }, + "action2": { + "exe": "./command.py", + "args": [ + "action2" + ] + } + } +} \ No newline at end of file