diff options
| author | Christoph Schlosser <christoph@linux.com> | 2025-08-31 01:09:37 +0200 |
|---|---|---|
| committer | Christoph Schlosser <christoph@linux.com> | 2025-08-31 15:53:33 +0200 |
| commit | 284f3972844ea124c0cd9ee5500e99440bb96aac (patch) | |
| tree | b8dee22222c38b12cc00daf98280e1b2060bcca7 /tests/log_test.py | |
| parent | b06dbf67b9ac9e329922d7911ee7a9b09419c5f0 (diff) | |
| download | git2hugo-284f3972844ea124c0cd9ee5500e99440bb96aac.tar.gz | |
g2h: Add file page
Also move helpers to dedicated files.
Diffstat (limited to 'tests/log_test.py')
| -rw-r--r-- | tests/log_test.py | 188 |
1 files changed, 0 insertions, 188 deletions
diff --git a/tests/log_test.py b/tests/log_test.py deleted file mode 100644 index 041544e..0000000 --- a/tests/log_test.py +++ /dev/null @@ -1,188 +0,0 @@ -from g2h.log_page import LogPage -from unittest.mock import MagicMock - -def test_init(): - page = LogPage('test/log', 'log test', 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, '') - context = page.context() - assert(context['title'] == 'log test: Log') - assert(context['commits'] == []) - -def test_context_no_branches_and_tags(): - commit = MagicMock() - commit.summary = 'mock commit' - commit.hexsha = 1234; - commit.committed_datetime = 0 - page = LogPage('test/log', 'log test', [commit], None, None, '') - context = page.context() - assert(context['title'] == 'log test: Log') - assert(context['commits'] == [{'committed_datetime': 0, 'hexsha': 1234, 'refs': [], 'summary': 'mock commit'}]) - -def test_context_matching_branch_no_tags(): - commit = MagicMock() - commit.summary = 'mock commit' - commit.hexsha = 1234; - commit.committed_datetime = 0 - branch = MagicMock() - branch.commit.hexsha = commit.hexsha - branch.name = 'mock branch' - page = LogPage('test/log', 'log test', [commit], [branch], None, '') - context = page.context() - assert(context['title'] == 'log test: Log') - assert(context['commits'] == [{'committed_datetime': 0, 'hexsha': 1234, 'refs': ['mock branch'], 'summary': 'mock commit'}]) - -def test_context_unmatching_branch_no_tags(): - commit = MagicMock() - commit.summary = 'mock commit' - commit.hexsha = 1234; - commit.committed_datetime = 0 - branch = MagicMock() - branch.commit.hexsha = 4321 - branch.name = 'mock branch' - page = LogPage('test/log', 'log test', [commit], [branch], None, '') - context = page.context() - assert(context['title'] == 'log test: Log') - assert(context['commits'] == [{'committed_datetime': 0, 'hexsha': 1234, 'refs': [], 'summary': 'mock commit'}]) - -def test_context_no_branch_matching_tag(): - commit = MagicMock() - commit.summary = 'mock commit' - commit.hexsha = 1234; - commit.committed_datetime = 0 - tag = MagicMock() - tag.commit.hexsha = commit.hexsha - tag.name = 'mock tag' - page = LogPage('test/log', 'log test', [commit], None, [tag], '') - context = page.context() - assert(context['commits'] == [{'committed_datetime': 0, 'hexsha': 1234, 'refs': ['mock tag'], 'summary': 'mock commit'}]) - -def test_context_no_branch_no_matching_tag(): - commit = MagicMock() - commit.summary = 'mock commit' - commit.hexsha = 1234; - commit.committed_datetime = 0 - tag = MagicMock() - tag.commit.hexsha = 4321 - tag.name = 'mock tag' - page = LogPage('test/log', 'log test', [commit], None, [tag], '') - context = page.context() - assert(context['title'] == 'log test: Log') - assert(context['commits'] == [{'committed_datetime': 0, 'hexsha': 1234, 'refs': [], 'summary': 'mock commit'}]) - -def test_context_no_matching_branch_no_matching_tag(): - commit = MagicMock() - commit.summary = 'mock commit' - commit.hexsha = 1234; - commit.committed_datetime = 0 - branch = MagicMock() - branch.commit.hexsha = 321 - branch.name = 'mock branch' - tag = MagicMock() - tag.commit.hexsha = 4321 - tag.name = 'mock tag' - page = LogPage('test/log', 'log test', [commit], [branch], [tag], '') - context = page.context() - assert(context['title'] == 'log test: Log') - assert(context['commits'] == [{'committed_datetime': 0, 'hexsha': 1234, 'refs': [], 'summary': 'mock commit'}]) - -def test_context_matching_branch_matching_tag(): - commit = MagicMock() - commit.summary = 'mock commit' - commit.hexsha = 1234; - commit.committed_datetime = 0 - branch = MagicMock() - branch.commit.hexsha = commit.hexsha - branch.name = 'mock branch' - tag = MagicMock() - tag.commit.hexsha = commit.hexsha - tag.name = 'mock tag' - page = LogPage('test/log', 'log test', [commit], [branch], [tag], '') - 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'}]) - -def test_multiple_commits(): - commit1 = MagicMock() - commit1.summary = 'mock commit 1' - commit1.hexsha = 1; - commit1.committed_datetime = 0 - commit2 = MagicMock() - commit2.summary = 'mock commit 2' - commit2.hexsha = 2; - commit2.committed_datetime = 1 - page = LogPage('test/log', 'log test', [commit1, commit2], None, None, '') - context = page.context() - assert(context['title'] == 'log test: Log') - assert(context['commits'] == [ - {'committed_datetime': 0, 'hexsha': 1, 'refs': [], 'summary': 'mock commit 1'}, - {'committed_datetime': 1, 'hexsha': 2, 'refs': [], 'summary': 'mock commit 2'} - ]) - -def test_multiple_commits_branch(): - commit1 = MagicMock() - commit1.summary = 'mock commit 1' - commit1.hexsha = 1; - commit1.committed_datetime = 0 - commit2 = MagicMock() - commit2.summary = 'mock commit 2' - commit2.hexsha = 2; - commit2.committed_datetime = 1 - branch = MagicMock() - branch.commit.hexsha = 1 - branch.name = 'mock branch' - page = LogPage('test/log', 'log test', [commit1, commit2], [branch], None, '') - context = page.context() - assert(context['title'] == 'log test: Log') - assert(context['commits'] == [ - {'committed_datetime': 0, 'hexsha': 1, 'refs': ['mock branch'], 'summary': 'mock commit 1'}, - {'committed_datetime': 1, 'hexsha': 2, 'refs': [], 'summary': 'mock commit 2'} - ]) - -def test_multiple_commits_tag(): - commit1 = MagicMock() - commit1.summary = 'mock commit 1' - commit1.hexsha = 1; - commit1.committed_datetime = 0 - commit2 = MagicMock() - commit2.summary = 'mock commit 2' - commit2.hexsha = 2; - commit2.committed_datetime = 1 - tag = MagicMock() - tag.commit.hexsha = 1 - tag.name = 'mock tag' - page = LogPage('test/log', 'log test', [commit1, commit2], None, [tag], '') - context = page.context() - assert(context['title'] == 'log test: Log') - assert(context['commits'] == [ - {'committed_datetime': 0, 'hexsha': 1, 'refs': ['mock tag'], 'summary': 'mock commit 1'}, - {'committed_datetime': 1, 'hexsha': 2, 'refs': [], 'summary': 'mock commit 2'} - ]) - -def test_multiple_commits_branch_and_tag(): - commit1 = MagicMock() - commit1.summary = 'mock commit 1' - commit1.hexsha = 1; - commit1.committed_datetime = 0 - commit2 = MagicMock() - commit2.summary = 'mock commit 2' - commit2.hexsha = 2; - commit2.committed_datetime = 1 - branch = MagicMock() - branch.commit.hexsha = 1 - branch.name = 'mock branch' - tag = MagicMock() - tag.commit.hexsha = 2 - tag.name = 'mock tag' - page = LogPage('test/log', 'log test', [commit1, commit2], [branch], [tag], '') - context = page.context() - assert(context['title'] == 'log test: Log') - assert(context['commits'] == [ - {'committed_datetime': 0, 'hexsha': 1, 'refs': ['mock branch'], 'summary': 'mock commit 1'}, - {'committed_datetime': 1, 'hexsha': 2, 'refs': ['mock tag'], 'summary': 'mock commit 2'} - ]) - |