From b3e0bcb8da7bea6c0b0636fdf68d0aac6ab74754 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Thu, 16 Sep 2021 12:23:54 +0200 Subject: Add a method to create an entry from a rendered template --- tests/data/simple/templates/new_entry_from_data.yaml | 12 ++++++++++++ .../data/simple/templates/new_entry_from_data_broken.yaml | 14 ++++++++++++++ .../simple/templates/new_entry_from_data_invalid_yaml.yaml | 13 +++++++++++++ .../simple/templates/new_entry_from_multiple_data.yaml | 12 ++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 tests/data/simple/templates/new_entry_from_data.yaml create mode 100644 tests/data/simple/templates/new_entry_from_data_broken.yaml create mode 100644 tests/data/simple/templates/new_entry_from_data_invalid_yaml.yaml create mode 100644 tests/data/simple/templates/new_entry_from_multiple_data.yaml (limited to 'tests/data/simple/templates') diff --git a/tests/data/simple/templates/new_entry_from_data.yaml b/tests/data/simple/templates/new_entry_from_data.yaml new file mode 100644 index 0000000..1f9e9a5 --- /dev/null +++ b/tests/data/simple/templates/new_entry_from_data.yaml @@ -0,0 +1,12 @@ +name: '{{ name }}' +description: | + {{ description if description else "." | indent(width=2, first=False) }} +position: '{{ position }}' +# # quantity (integer): how many items are there +quantity: {{ quantity if quantity else "0" }} +# # value (float): how much each item is +value: 0.0 +# # cost (decimal): how much this costs +cost: '0' +# # other (yaml): +other: diff --git a/tests/data/simple/templates/new_entry_from_data_broken.yaml b/tests/data/simple/templates/new_entry_from_data_broken.yaml new file mode 100644 index 0000000..73798ce --- /dev/null +++ b/tests/data/simple/templates/new_entry_from_data_broken.yaml @@ -0,0 +1,14 @@ +name: '{{ name }}' +description: | + {{ description if description else "." indent(width=2, first=False) }} + # Note that the lack of | between "." and indent is wanted, to get a proper + # TemplatingError. +position: '{{ position }}' +# quantity (integer): how many items are there +quantity: {{ quantity if quantity else "0" }} +# value (float): how much each item is +value: 0.0 +# cost (decimal): how much this costs +cost: '0' +# other (yaml): +other: diff --git a/tests/data/simple/templates/new_entry_from_data_invalid_yaml.yaml b/tests/data/simple/templates/new_entry_from_data_invalid_yaml.yaml new file mode 100644 index 0000000..7493947 --- /dev/null +++ b/tests/data/simple/templates/new_entry_from_data_invalid_yaml.yaml @@ -0,0 +1,13 @@ +# A : in that position should result in invalid yaml +name: '{{ name }}': some text +description: | + {{ description if description else "." | indent(width=2, first=False) }} +position: '{{ position }}' +# # quantity (integer): how many items are there +quantity: {{ quantity if quantity else "0" }} +# # value (float): how much each item is +value: 0.0 +# # cost (decimal): how much this costs +cost: '0' +# # other (yaml): +other: diff --git a/tests/data/simple/templates/new_entry_from_multiple_data.yaml b/tests/data/simple/templates/new_entry_from_multiple_data.yaml new file mode 100644 index 0000000..cfa4296 --- /dev/null +++ b/tests/data/simple/templates/new_entry_from_multiple_data.yaml @@ -0,0 +1,12 @@ +name: '{{ data.name }}' +description: | + {{ description if description else "." | indent(width=2, first=False) }} +position: '{{ data.position }}' +# # quantity (integer): how many items are there +quantity: {{ values.quantity if values.quantity else "0" }} +# # value (float): how much each item is +value: 0.0 +# # cost (decimal): how much this costs +cost: '{{ values.cost if values.cost else "0.0" }}' +# # other (yaml): +other: -- cgit v1.2.3