diff options
| author | Christoph Schlosser <christoph@linux.com> | 2025-08-24 18:58:26 +0200 |
|---|---|---|
| committer | Christoph Schlosser <christoph@linux.com> | 2025-08-24 18:58:26 +0200 |
| commit | bfb9afa2a57c3c302dde2c9669425d365c3f9b40 (patch) | |
| tree | b0f3f327becfd078b16ff777cde3b1ba93885954 /tests/commit_test.py | |
| parent | 3d06cd01a52382982964a2c40036ca1dabb76501 (diff) | |
| download | git2hugo-bfb9afa2a57c3c302dde2c9669425d365c3f9b40.tar.gz | |
g2h: Add redacted authors email to commit page
Diffstat (limited to 'tests/commit_test.py')
| -rw-r--r-- | tests/commit_test.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/commit_test.py b/tests/commit_test.py index 1d79f1e..3a9871a 100644 --- a/tests/commit_test.py +++ b/tests/commit_test.py @@ -1,4 +1,4 @@ -from g2h.commit_page import CommitPage +from g2h.commit_page import CommitPage, redact_email from unittest.mock import MagicMock def test_init(): @@ -12,8 +12,25 @@ def test_init(): def test_context(): commit = MagicMock() commit.hexsha = '123' + commit.author.email = 'unit@te.st' page = CommitPage('test/commit', 'commit test', commit, '') context = page.context() assert(context['title'] == 'commit test: 123') assert(context['commit'] == commit) + assert(context['redacted_email'] == 'u...t@te...st') +def test_redacting_email(): + assert(redact_email(None) == '') + assert(redact_email('') == '') + assert(redact_email('a') == 'a...a') + assert(redact_email('az') == 'a...z') + assert(redact_email('root') == 'r...t') + assert(redact_email('root@localhost') == 'r...t@localhost') + assert(redact_email('test@example.com') == 't...t@example...com') + assert(redact_email('test@sub.example.com') == 't...t@sub...example...com') + assert(redact_email('az@example.com') == 'a...z@example...com') + assert(redact_email('a@example.com') == 'a...a@example...com') + assert(redact_email('@example.com') == '@example...com') + assert(redact_email('test@') == 't...t@') + assert(redact_email('az@') == 'a...z@') + assert(redact_email('@') == '@') |