summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristoph Schlosser <christoph@linux.com>2025-09-18 23:17:24 +0200
committerChristoph Schlosser <christoph@linux.com>2025-09-18 23:17:24 +0200
commitbd403e6ab18d5cc7818e86d43c3ca0b15c5e53a1 (patch)
treed9abea372078840e69e38401bce663b00dfbe07e /tests
parent2a592ecd951f758a62b1c4907e5da212cf1ba264 (diff)
downloadgit2hugo-bd403e6ab18d5cc7818e86d43c3ca0b15c5e53a1.tar.gz
g2h: Add navbar
Diffstat (limited to 'tests')
-rw-r--r--tests/commit_page_test.py1
-rw-r--r--tests/file_page_test.py1
-rw-r--r--tests/log_page_test.py27
-rw-r--r--tests/overview_page_test.py2
-rw-r--r--tests/tree_page_test.py1
5 files changed, 19 insertions, 13 deletions
diff --git a/tests/commit_page_test.py b/tests/commit_page_test.py
index bfff3c4..2078ed3 100644
--- a/tests/commit_page_test.py
+++ b/tests/commit_page_test.py
@@ -19,6 +19,7 @@ def test_context():
assert(context['commit'] == commit)
assert(context['redacted_email'] == 'u...@te.st')
assert(context['content_subdir'] == 'commit/content')
+ assert(context['this_commit'] == commit)
def test_redacting_email():
assert(redact_email(None) == '')
diff --git a/tests/file_page_test.py b/tests/file_page_test.py
index 3fff51e..097f5a1 100644
--- a/tests/file_page_test.py
+++ b/tests/file_page_test.py
@@ -42,6 +42,7 @@ def test_context():
assert(context['title'] == 'file test: test_file.txt')
assert(context['type'] == 'text')
assert(context['breadcrumbs'] == '[/](/file/content/123/t/)/[test_file.txt](/file/content/123/t/test_file.txt)')
+ assert(context['this_commit'] == commit)
def test_context_dot_file():
file = MagicMock()
diff --git a/tests/log_page_test.py b/tests/log_page_test.py
index 041544e..da00fd0 100644
--- a/tests/log_page_test.py
+++ b/tests/log_page_test.py
@@ -2,13 +2,13 @@ from g2h.log_page import LogPage
from unittest.mock import MagicMock
def test_init():
- page = LogPage('test/log', 'log test', None, None, None, '')
+ page = LogPage('test/log', 'log test', None, None, None, '', None)
assert(page.name == 'log test')
assert(page.out_file_path == 'test/log/l.md')
assert(page.template.name == 'log.md')
def test_context_no_commits():
- page = LogPage('test/log', 'log test', None, None, None, '')
+ page = LogPage('test/log', 'log test', None, None, None, '', None)
context = page.context()
assert(context['title'] == 'log test: Log')
assert(context['commits'] == [])
@@ -18,10 +18,11 @@ def test_context_no_branches_and_tags():
commit.summary = 'mock commit'
commit.hexsha = 1234;
commit.committed_datetime = 0
- page = LogPage('test/log', 'log test', [commit], None, None, '')
+ page = LogPage('test/log', 'log test', [commit], None, None, '', commit)
context = page.context()
assert(context['title'] == 'log test: Log')
assert(context['commits'] == [{'committed_datetime': 0, 'hexsha': 1234, 'refs': [], 'summary': 'mock commit'}])
+ assert(context['this_commit'] == commit)
def test_context_matching_branch_no_tags():
commit = MagicMock()
@@ -31,7 +32,7 @@ def test_context_matching_branch_no_tags():
branch = MagicMock()
branch.commit.hexsha = commit.hexsha
branch.name = 'mock branch'
- page = LogPage('test/log', 'log test', [commit], [branch], None, '')
+ page = LogPage('test/log', 'log test', [commit], [branch], None, '', None)
context = page.context()
assert(context['title'] == 'log test: Log')
assert(context['commits'] == [{'committed_datetime': 0, 'hexsha': 1234, 'refs': ['mock branch'], 'summary': 'mock commit'}])
@@ -44,7 +45,7 @@ def test_context_unmatching_branch_no_tags():
branch = MagicMock()
branch.commit.hexsha = 4321
branch.name = 'mock branch'
- page = LogPage('test/log', 'log test', [commit], [branch], None, '')
+ page = LogPage('test/log', 'log test', [commit], [branch], None, '', None)
context = page.context()
assert(context['title'] == 'log test: Log')
assert(context['commits'] == [{'committed_datetime': 0, 'hexsha': 1234, 'refs': [], 'summary': 'mock commit'}])
@@ -57,7 +58,7 @@ def test_context_no_branch_matching_tag():
tag = MagicMock()
tag.commit.hexsha = commit.hexsha
tag.name = 'mock tag'
- page = LogPage('test/log', 'log test', [commit], None, [tag], '')
+ page = LogPage('test/log', 'log test', [commit], None, [tag], '', None)
context = page.context()
assert(context['commits'] == [{'committed_datetime': 0, 'hexsha': 1234, 'refs': ['mock tag'], 'summary': 'mock commit'}])
@@ -69,7 +70,7 @@ def test_context_no_branch_no_matching_tag():
tag = MagicMock()
tag.commit.hexsha = 4321
tag.name = 'mock tag'
- page = LogPage('test/log', 'log test', [commit], None, [tag], '')
+ page = LogPage('test/log', 'log test', [commit], None, [tag], '', None)
context = page.context()
assert(context['title'] == 'log test: Log')
assert(context['commits'] == [{'committed_datetime': 0, 'hexsha': 1234, 'refs': [], 'summary': 'mock commit'}])
@@ -85,7 +86,7 @@ def test_context_no_matching_branch_no_matching_tag():
tag = MagicMock()
tag.commit.hexsha = 4321
tag.name = 'mock tag'
- page = LogPage('test/log', 'log test', [commit], [branch], [tag], '')
+ page = LogPage('test/log', 'log test', [commit], [branch], [tag], '', None)
context = page.context()
assert(context['title'] == 'log test: Log')
assert(context['commits'] == [{'committed_datetime': 0, 'hexsha': 1234, 'refs': [], 'summary': 'mock commit'}])
@@ -101,7 +102,7 @@ def test_context_matching_branch_matching_tag():
tag = MagicMock()
tag.commit.hexsha = commit.hexsha
tag.name = 'mock tag'
- page = LogPage('test/log', 'log test', [commit], [branch], [tag], '')
+ page = LogPage('test/log', 'log test', [commit], [branch], [tag], '', None)
context = page.context()
assert(context['title'] == 'log test: Log')
assert(context['commits'] == [{'committed_datetime': 0, 'hexsha': 1234, 'refs': ['mock branch', 'mock tag'], 'summary': 'mock commit'}])
@@ -115,7 +116,7 @@ def test_multiple_commits():
commit2.summary = 'mock commit 2'
commit2.hexsha = 2;
commit2.committed_datetime = 1
- page = LogPage('test/log', 'log test', [commit1, commit2], None, None, '')
+ page = LogPage('test/log', 'log test', [commit1, commit2], None, None, '', None)
context = page.context()
assert(context['title'] == 'log test: Log')
assert(context['commits'] == [
@@ -135,7 +136,7 @@ def test_multiple_commits_branch():
branch = MagicMock()
branch.commit.hexsha = 1
branch.name = 'mock branch'
- page = LogPage('test/log', 'log test', [commit1, commit2], [branch], None, '')
+ page = LogPage('test/log', 'log test', [commit1, commit2], [branch], None, '', None)
context = page.context()
assert(context['title'] == 'log test: Log')
assert(context['commits'] == [
@@ -155,7 +156,7 @@ def test_multiple_commits_tag():
tag = MagicMock()
tag.commit.hexsha = 1
tag.name = 'mock tag'
- page = LogPage('test/log', 'log test', [commit1, commit2], None, [tag], '')
+ page = LogPage('test/log', 'log test', [commit1, commit2], None, [tag], '', None)
context = page.context()
assert(context['title'] == 'log test: Log')
assert(context['commits'] == [
@@ -178,7 +179,7 @@ def test_multiple_commits_branch_and_tag():
tag = MagicMock()
tag.commit.hexsha = 2
tag.name = 'mock tag'
- page = LogPage('test/log', 'log test', [commit1, commit2], [branch], [tag], '')
+ page = LogPage('test/log', 'log test', [commit1, commit2], [branch], [tag], '', None)
context = page.context()
assert(context['title'] == 'log test: Log')
assert(context['commits'] == [
diff --git a/tests/overview_page_test.py b/tests/overview_page_test.py
index 1d94acf..d2b3f82 100644
--- a/tests/overview_page_test.py
+++ b/tests/overview_page_test.py
@@ -5,6 +5,7 @@ from g2h.overview_page import OverviewPage
def test_init():
commit = Mock()
commit.committed_datetime = '2025-04-01T12:34:56+00:00'
+ commit.hexsha = 'abc'
page = OverviewPage('test/overview', 'overview test', 'test branch', 'test tag', 'overview/sub/dir', commit)
context = page.context()
assert(context['title'] == 'overview test')
@@ -12,3 +13,4 @@ def test_init():
assert(context['tags'] == 'test tag')
assert(context['content_subdir'] == 'overview/sub/dir')
assert(context['latest_commit_date'] == '2025-04-01T12:34:56+00:00')
+ assert(context['this_commit'] == commit)
diff --git a/tests/tree_page_test.py b/tests/tree_page_test.py
index a298728..57084d1 100644
--- a/tests/tree_page_test.py
+++ b/tests/tree_page_test.py
@@ -54,6 +54,7 @@ def test_context_empty():
assert(context['subdir'] == '/123/t/tree/path')
assert(context['title'] == 'tree test: Tree')
assert(context['breadcrumbs'] == '[/](/123/t/)')
+ assert(context['this_commit'] == commit)
def test_context_entries():
tree = MagicMock()