Add a test source to hit every render path

This commit is contained in:
Tim Van Baak 2023-07-27 12:53:57 -07:00
parent a4adbff8f6
commit 0ae5a77844
2 changed files with 92 additions and 0 deletions

70
tests/demo_items/command.py Executable file
View File

@ -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": "<p>Hello, intake! This is an <b>item</b> body.</p>",
})
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": "<p>This is body text.</p>",
"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": "<p>This is body text.</p>",
})
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))

View File

@ -0,0 +1,22 @@
{
"action": {
"fetch": {
"exe": "./command.py",
"args": [
"fetch"
]
},
"action1": {
"exe": "./command.py",
"args": [
"action1"
]
},
"action2": {
"exe": "./command.py",
"args": [
"action2"
]
}
}
}