~tieong/notjinja2

62fc87ac5f4bf5fb1d9ef94ad1786ef0bfb9b0c4 — Thomas Ieong 1 year, 7 months ago 1e2cfee
Added another template test
1 files changed, 20 insertions(+), 0 deletions(-)

M tests/test_templates.py
M tests/test_templates.py => tests/test_templates.py +20 -0
@@ 58,6 58,26 @@ class TestTemplates(unittest.TestCase):
            "    <p>Welcome, Donald!</p><p>Products:</p><ul>    <li>foo: 100</li>    <ul>                         <li>foo: 100</li>                                 <li>boo: 200</li>                  </ul>       <li>boo: 200</li>    <ul>                         <li>foo: 100</li>                                 <li>boo: 200</li>                  </ul>       <p>Priority: HIGH</p></ul>",
        )

    def test_template3(self):
        path = Path.cwd() / "templates" / "acces_dict.html"
        with path.open(encoding="utf-8") as f:
            template = Template(
                f.read(),
                {
                    "user": User(True, "Donald"),
                    "product_list": {"a":Product("foo", 10), "b": Product("boo", 20)},
                    "format_price": Product.format_price,
                    "priority": "HIGH",
                    "priority_low": "LOW",
                    "data": {"HIGH": 1, "MID": 2, "LOW": 3},
                },
            )
        result = template.render()
        self.assertEqual(
            result,
            "    <p>Welcome, Donald!</p><p>Products:</p><ul>        <li>a: foo</li>        <li>b: boo</li>    </ul>",
        )


if __name__ == "__main__":
    unittest.main()