summaryrefslogtreecommitdiff
path: root/subplot
diff options
context:
space:
mode:
Diffstat (limited to 'subplot')
-rw-r--r--subplot/jt.py29
-rw-r--r--subplot/jt.yaml6
2 files changed, 29 insertions, 6 deletions
diff --git a/subplot/jt.py b/subplot/jt.py
index 31bceb7..312a22a 100644
--- a/subplot/jt.py
+++ b/subplot/jt.py
@@ -65,17 +65,22 @@ def output_contains(ctx, pattern=None):
def journal_has_no_drafts(ctx, dirname=None):
- assert_eq = globals()["assert_eq"]
- logging.debug(f"checking {dirname} has no drafts")
- drafts = os.path.join(dirname, "drafts")
- assert_eq(_find_files(drafts), [])
+ _journal_has_n_drafts(ctx, 0, dirname=dirname)
def journal_has_one_draft(ctx, dirname=None):
+ _journal_has_n_drafts(ctx, 1, dirname=dirname)
+
+
+def journal_has_two_drafts(ctx, dirname=None):
+ _journal_has_n_drafts(ctx, 2, dirname=dirname)
+
+
+def _journal_has_n_drafts(ctx, n, dirname=None):
assert_eq = globals()["assert_eq"]
- logging.debug(f"checking {dirname} has one draft")
+ logging.debug(f"checking {dirname} has {n} drafts")
drafts = os.path.join(dirname, "drafts")
- assert_eq(len(_find_files(drafts)), 1)
+ assert_eq(len(_find_files(drafts)), n)
def journal_has_no_entries(ctx, dirname=None):
@@ -98,6 +103,18 @@ def journal_has_one_entry(ctx, dirname=None, variable=None):
ctx["variables"] = variables
+def journal_has_two_entries(ctx, dirname=None, variable1=None, variable2=None):
+ assert_eq = globals()["assert_eq"]
+ logging.debug(f"checking {dirname} has two entries")
+ entries = os.path.join(dirname, "entries")
+ files = list(sorted(_find_files(entries)))
+ assert_eq(len(files), 2)
+ variables = ctx.get("variables", {})
+ variables[variable1] = files[0]
+ variables[variable2] = files[1]
+ ctx["variables"] = variables
+
+
def _find_files(root):
if not os.path.exists(root):
return []
diff --git a/subplot/jt.yaml b/subplot/jt.yaml
index 9c0983c..187f436 100644
--- a/subplot/jt.yaml
+++ b/subplot/jt.yaml
@@ -37,6 +37,9 @@
- then: there is one draft in {dirname}
function: journal_has_one_draft
+- then: there are two drafts in {dirname}
+ function: journal_has_two_drafts
+
- then: draft {draftno} in {dirname} contains "{pattern:text}"
function: draft_contains_string
@@ -46,5 +49,8 @@
- then: there is one journal entry in {dirname}, at {variable}
function: journal_has_one_entry
+- then: there are two journal entries in {dirname}, at {variable1} and {variable2}
+ function: journal_has_two_entries
+
- then: journal entry <{variable}> contains "{pattern:text}"
function: file_contains