From b6210b2dd20d4bfe5d4a2c14aa2b075ea7d4c312 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 17 Jan 2021 17:27:43 +0200 Subject: initial version --- check | 9 +++++++++ my-sites.md | 19 +++++++++++++++++++ my-sites.py | 11 +++++++++++ my-sites.yaml | 5 +++++ 4 files changed, 44 insertions(+) create mode 100755 check create mode 100644 my-sites.md create mode 100644 my-sites.py create mode 100644 my-sites.yaml diff --git a/check b/check new file mode 100755 index 0000000..6fa29e0 --- /dev/null +++ b/check @@ -0,0 +1,9 @@ +#!/bin/bash + +set -euo pipefail + +sp-docgen my-sites.md -o my-sites.html +sp-docgen my-sites.md -o my-sites.pdf +sp-codegen my-sites.md -o test.py +rm -f test.log +python3 test.py --log test.log "$@" diff --git a/my-sites.md b/my-sites.md new file mode 100644 index 0000000..e2b67ab --- /dev/null +++ b/my-sites.md @@ -0,0 +1,19 @@ +# Introduction + +This is a simplistic set of acceptance criteria for my various +websites. + +# liw.fi + +~~~scenario +when I fetch https://liw.fi +then page contains "I am Lars Wirzenius" +~~~ + +--- +title: Do my sites work? +author: Lars Wirzenius +template: python +bindings: my-sites.yaml +functions: my-sites.py +... diff --git a/my-sites.py b/my-sites.py new file mode 100644 index 0000000..f01eea9 --- /dev/null +++ b/my-sites.py @@ -0,0 +1,11 @@ +import requests + +def fetch(ctx, url=None): + r = requests.get(url) + assert r.ok + ctx["page"] = r.text + +def contains(ctx, text=None): + if text not in ctx["page"]: + print(f"page does not contain {text!r}") + assert 0 diff --git a/my-sites.yaml b/my-sites.yaml new file mode 100644 index 0000000..a1783fa --- /dev/null +++ b/my-sites.yaml @@ -0,0 +1,5 @@ +- when: I fetch {url} + function: fetch + +- then: page contains "{text:text}" + function: contains -- cgit v1.2.1