From 7a86aa1d1733938d029fc08d2b6b835cfebdffb1 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 21 Mar 2019 11:08:22 -0700 Subject: [PATCH] pylorax.ltmpl: Add a test for missing quotes It should raise an error if a quote is missing in the template. (cherry picked from commit df3aeee8025dc9c100e0a96a0f474773bbdf9c8b) (cherry picked from commit 1d4f47e26f83b813d8674dfcb8b1a28758c108c7) --- tests/pylorax/templates/parse-missing-quote.tmpl | 4 ++++ tests/pylorax/test_ltmpl.py | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 tests/pylorax/templates/parse-missing-quote.tmpl diff --git a/tests/pylorax/templates/parse-missing-quote.tmpl b/tests/pylorax/templates/parse-missing-quote.tmpl new file mode 100644 index 00000000..ebcb343f --- /dev/null +++ b/tests/pylorax/templates/parse-missing-quote.tmpl @@ -0,0 +1,4 @@ +<%page args="basearch"/> + +# missing quote +replace @ROOT@ 'inst.stage2=hd:LABEL=foo isolinux.cfg diff --git a/tests/pylorax/test_ltmpl.py b/tests/pylorax/test_ltmpl.py index 91704039..7af91fdd 100644 --- a/tests/pylorax/test_ltmpl.py +++ b/tests/pylorax/test_ltmpl.py @@ -58,6 +58,11 @@ class LoraxTemplateTestCase(unittest.TestCase): def setUpClass(self): self.templates = LoraxTemplate(["./tests/pylorax/templates/"]) + def test_parse_missing_quote(self): + """Test parsing a template with missing quote""" + with self.assertRaises(Exception): + self.templates.parse("parse-missing-quote.tmpl", {"basearch": "x86_64"}) + def test_parse_template_x86_64(self): """Test LoraxTemplate.parse() with basearch set to x86_64""" commands = self.templates.parse("parse-test.tmpl", {"basearch": "x86_64"})