From b6628dbc405cf6ed0d63a481321954d1a3fbe79d Mon Sep 17 00:00:00 2001 From: Inengiye Emmanuel Date: Tue, 17 Mar 2026 20:08:26 +0100 Subject: [PATCH 1/2] Add unit tests for check_swapped_emails Signed-off-by: Inengiye Emmanuel --- .../test_util/test_check_swapped_emails.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/test_tasks/test_task_utilities/test_util/test_check_swapped_emails.py diff --git a/tests/test_tasks/test_task_utilities/test_util/test_check_swapped_emails.py b/tests/test_tasks/test_task_utilities/test_util/test_check_swapped_emails.py new file mode 100644 index 0000000000..3658f0d360 --- /dev/null +++ b/tests/test_tasks/test_task_utilities/test_util/test_check_swapped_emails.py @@ -0,0 +1,34 @@ +import pytest +from augur.tasks.git.util.facade_worker.facade_worker.analyzecommit import check_swapped_emails + +def test_correct_input_unchanged(): + name, email = check_swapped_emails("John Smith", "john@gmail.com") + assert name == "John Smith" + assert email == "john@gmail.com" + +def test_swapped_input_is_corrected(): + name, email = check_swapped_emails("john@gmail.com", "John Smith") + assert name == "John Smith" + assert email == "john@gmail.com" + +def test_name_field_contains_mixed_name_and_email(): + # name field has both a name and email mixed together + name, email = check_swapped_emails("John Smith john@gmail.com", "") + assert name == "John Smith john@gmail.com" + assert email == "" + +def test_email_field_contains_mixed_name_and_email(): + # email field has both a name and email mixed together + name, email = check_swapped_emails("John Smith", "John Smith john@gmail.com") + assert name == "John Smith" + assert email == "John Smith john@gmail.com" + +def test_both_fields_contain_mixed_name_and_email(): + name, email = check_swapped_emails("John Smith john@gmail.com", "Jane Doe jane@gmail.com") + assert name == "John Smith john@gmail.com" + assert email == "Jane Doe jane@gmail.com" + +def test_when_both_empty_strings(): + name, email = check_swapped_emails("", "") + assert name == "" + assert email == "" From 10c0e2a1c92a9b22e4fae0bba9e7bb22fe933e7c Mon Sep 17 00:00:00 2001 From: Inengiye Emmanuel Date: Mon, 30 Mar 2026 05:20:39 +0100 Subject: [PATCH 2/2] Add test for email with multiple @ signs Signed-off-by: Inengiye Emmanuel --- .../test_util/test_check_swapped_emails.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_tasks/test_task_utilities/test_util/test_check_swapped_emails.py b/tests/test_tasks/test_task_utilities/test_util/test_check_swapped_emails.py index 3658f0d360..0032c23dfc 100644 --- a/tests/test_tasks/test_task_utilities/test_util/test_check_swapped_emails.py +++ b/tests/test_tasks/test_task_utilities/test_util/test_check_swapped_emails.py @@ -32,3 +32,8 @@ def test_when_both_empty_strings(): name, email = check_swapped_emails("", "") assert name == "" assert email == "" + +def test_email_with_multiple_at_signs(): + name, email = check_swapped_emails("John Smith", "john@@gmail.com") + assert name == "John Smith" + assert email == "john@@gmail.com" \ No newline at end of file