From 560beb41d1f229d6e8a9f6bd097b0baa6b7814e3 Mon Sep 17 00:00:00 2001 From: Bastian Venthur Date: Mon, 22 Feb 2021 20:41:12 +0100 Subject: [PATCH] added tests for built-in templates page and article --- tests/test_templates.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/test_templates.py diff --git a/tests/test_templates.py b/tests/test_templates.py new file mode 100644 index 0000000..bf002cd --- /dev/null +++ b/tests/test_templates.py @@ -0,0 +1,40 @@ +from jinja2 import Environment, PackageLoader +import pytest + + +@pytest.fixture +def environment(): + env = Environment( + loader=PackageLoader('blag', 'templates') + ) + yield env + + +@pytest.fixture +def page_template(environment): + yield environment.get_template('page.html') + + +@pytest.fixture +def article_template(environment): + yield environment.get_template('article.html') + + +def test_page(page_template): + ctx = { + 'content': 'this is the content', + 'title': 'this is the title', + } + result = page_template.render(ctx) + assert 'this is the content' in result + assert 'this is the title' in result + + +def test_article(article_template): + ctx = { + 'content': 'this is the content', + 'title': 'this is the title', + } + result = article_template.render(ctx) + assert 'this is the content' in result + assert 'this is the title' in result