Split Archive into Index and Archive

This commit is contained in:
Bastian Venthur
2023-05-31 15:53:49 +02:00
parent a3572d414f
commit 362e721d88
9 changed files with 108 additions and 8 deletions

View File

@@ -33,6 +33,11 @@ def article_template(environment: Environment) -> Iterator[Template]:
yield environment.get_template('article.html')
@pytest.fixture
def index_template(environment: Environment) -> Iterator[Template]:
yield environment.get_template('index.html')
@pytest.fixture
def archive_template(environment: Environment) -> Iterator[Template]:
yield environment.get_template('archive.html')

View File

@@ -291,8 +291,10 @@ foo bar
assert os.path.exists(f'{args.output_dir}/testdir/test')
# ... feed
assert os.path.exists(f'{args.output_dir}/atom.xml')
# ... archive
# ... index
assert os.path.exists(f'{args.output_dir}/index.html')
# ... archive
assert os.path.exists(f'{args.output_dir}/archive.html')
# ... tags
assert os.path.exists(f'{args.output_dir}/tags/index.html')
assert os.path.exists(f'{args.output_dir}/tags/foo.html')

View File

@@ -27,6 +27,26 @@ def test_article(article_template: Template) -> None:
assert '1980-05-09' in result
def test_index(index_template: Template) -> None:
entry = {
'title': 'this is a title',
'dst': 'https://example.com/link',
'date': datetime.datetime(1980, 5, 9),
}
archive = [entry]
ctx = {
'archive': archive,
}
result = index_template.render(ctx)
assert 'site title' in result
assert 'this is a title' in result
assert '1980-05-09' in result
assert 'https://example.com/link' in result
assert '/archive.html' in result
def test_archive(archive_template: Template) -> None:
entry = {
'title': 'this is a title',
@@ -38,7 +58,7 @@ def test_archive(archive_template: Template) -> None:
'archive': archive,
}
result = archive_template.render(ctx)
assert 'site title' in result
assert 'Archive' in result
assert 'this is a title' in result
assert '1980-05-09' in result