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

added global site variables to environment

This commit is contained in:
Bastian Venthur
2021-03-08 21:35:51 +01:00
parent 3874d19371
commit d778d01e78
5 changed files with 57 additions and 13 deletions

View File

@@ -1,14 +1,19 @@
import datetime
from jinja2 import Environment, PackageLoader
import pytest
from blag import blag
@pytest.fixture
def environment():
env = Environment(
loader=PackageLoader('blag', 'templates')
)
site = {
'base_url': 'site base_url',
'title': 'site title',
'description': 'site description',
'author': 'site author',
}
env = blag.environment_factory(globals_=dict(site=site))
yield env
@@ -65,11 +70,10 @@ def test_archive(archive_template):
}
archive = [entry]
ctx = {
'title': 'this is the title',
'archive': archive,
}
result = archive_template.render(ctx)
assert 'this is the title' in result
assert 'site title' in result
assert 'this is a title' in result
assert '1980-05-09' in result