mirror of
https://github.com/venthur/blag.git
synced 2025-11-25 12:42:41 +00:00
added tests for built-in templates page and article
This commit is contained in:
40
tests/test_templates.py
Normal file
40
tests/test_templates.py
Normal 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
|
||||
Reference in New Issue
Block a user