From 17a1eb53cc970a5030421b3c03e6c2c32cd7e2f0 Mon Sep 17 00:00:00 2001 From: Bastian Venthur Date: Mon, 22 Feb 2021 21:07:00 +0100 Subject: [PATCH] added template test for archive --- tests/test_templates.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test_templates.py b/tests/test_templates.py index bf002cd..7455e4a 100644 --- a/tests/test_templates.py +++ b/tests/test_templates.py @@ -1,3 +1,5 @@ +import datetime + from jinja2 import Environment, PackageLoader import pytest @@ -20,6 +22,11 @@ def article_template(environment): yield environment.get_template('article.html') +@pytest.fixture +def archive_template(environment): + yield environment.get_template('archive.html') + + def test_page(page_template): ctx = { 'content': 'this is the content', @@ -38,3 +45,22 @@ def test_article(article_template): result = article_template.render(ctx) assert 'this is the content' in result assert 'this is the title' in result + + +def test_archive(archive_template): + entry = { + 'title': 'this is a title', + 'dst': 'https://example.com/link', + 'date': datetime.datetime(1980, 5, 9), + } + archive = [entry] + ctx = { + 'title': 'this is the title', + 'archive': archive, + } + result = archive_template.render(ctx) + assert 'this is the title' in result + + assert 'this is a title' in result + assert '1980-05-09' in result + assert 'https://example.com/link' in result