1
0
mirror of https://github.com/venthur/blag.git synced 2025-11-25 20:52:43 +00:00

added tests for built-in templates page and article

This commit is contained in:
Bastian Venthur
2021-02-22 20:41:12 +01:00
parent 8f8a89f1eb
commit 560beb41d1

40
tests/test_templates.py Normal file
View File

@@ -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