From e7fa1470b72daaa9b2edb88ddc60bde912a6bb46 Mon Sep 17 00:00:00 2001 From: Bastian Venthur Date: Mon, 22 Feb 2021 21:07:23 +0100 Subject: [PATCH] added template test for tag and tags --- tests/test_templates.py | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/test_templates.py b/tests/test_templates.py index 7455e4a..3d91d2b 100644 --- a/tests/test_templates.py +++ b/tests/test_templates.py @@ -27,6 +27,16 @@ def archive_template(environment): yield environment.get_template('archive.html') +@pytest.fixture +def tags_template(environment): + yield environment.get_template('tags.html') + + +@pytest.fixture +def tag_template(environment): + yield environment.get_template('tag.html') + + def test_page(page_template): ctx = { 'content': 'this is the content', @@ -64,3 +74,35 @@ def test_archive(archive_template): assert 'this is a title' in result assert '1980-05-09' in result assert 'https://example.com/link' in result + + +def test_tags(tags_template): + tags = [('foo', 42)] + ctx = { + 'tags': tags, + } + result = tags_template.render(ctx) + assert 'Tags' in result + + assert 'foo.html' in result + assert 'foo' in result + assert '42' in result + + +def test_tag(tag_template): + entry = { + 'title': 'this is a title', + 'dst': 'https://example.com/link', + 'date': datetime.datetime(1980, 5, 9), + } + archive = [entry] + ctx = { + 'tag': 'foo', + 'archive': archive, + } + result = tag_template.render(ctx) + assert 'Tag foo' in result + + assert 'this is a title' in result + assert '1980-05-09' in result + assert 'https://example.com/link' in result