Skip to content

Commit e45b50a

Browse files
committed
update unit tests
1 parent 4550117 commit e45b50a

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

tests/test_main.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,8 @@ def test_process_repositories_archiving(self, mock_rest, mock_logger):
569569
interfaces, org, repositories, archive_criteria, notification_content
570570
)
571571

572-
assert repositories_archived == 1
573-
assert issues_created == 0
572+
assert repositories_archived == ["repo1"]
573+
assert issues_created == []
574574
mock_rest_instance.patch.assert_called_once_with(f"/repos/{org}/repo1", {"archived": True})
575575

576576
@patch("src.main.wrapped_logging")
@@ -602,8 +602,8 @@ def test_process_repositories_create_issue(self, mock_rest, mock_logger):
602602
interfaces, org, repositories, archive_criteria, notification_content
603603
)
604604

605-
assert repositories_archived == 0
606-
assert issues_created == 1
605+
assert repositories_archived == []
606+
assert issues_created == ["repo1"]
607607
mock_rest_instance.post.assert_called_once_with(
608608
f"/repos/{org}/repo1/issues",
609609
{
@@ -635,8 +635,8 @@ def test_process_repositories_skip_recent_update(self, mock_rest, mock_logger):
635635
interfaces, org, repositories, archive_criteria, notification_content
636636
)
637637

638-
assert repositories_archived == 0
639-
assert issues_created == 0
638+
assert repositories_archived == []
639+
assert issues_created == []
640640
mock_rest_instance.post.assert_not_called()
641641
mock_rest_instance.patch.assert_not_called()
642642

@@ -693,8 +693,8 @@ def test_process_repositories_max_notifications(self, mock_rest, mock_logger):
693693
interfaces, org, repositories, archive_criteria, notification_content
694694
)
695695

696-
assert repositories_archived == 0
697-
assert issues_created == 5 # noqa: PLR2004
696+
assert repositories_archived == []
697+
assert issues_created == ["repo1", "repo2", "repo3", "repo4", "repo5"] # noqa: PLR2004
698698
assert mock_rest_instance.post.call_count == 5 # noqa: PLR2004
699699
mock_logger_instance.log_info.assert_called_with(
700700
"Maximum number of notifications reached. No more notifications will be made."
@@ -731,8 +731,8 @@ def test_process_repositories_issue_not_meeting_notification_period(self, mock_r
731731
interfaces, org, repositories, archive_criteria, notification_content
732732
)
733733

734-
assert repositories_archived == 0
735-
assert issues_created == 0
734+
assert repositories_archived == []
735+
assert issues_created == []
736736
mock_rest_instance.post.assert_not_called()
737737
mock_rest_instance.patch.assert_not_called()
738738

@@ -794,8 +794,8 @@ def test_process_repositories_issue_logging(self, mock_rest, mock_logger):
794794
interfaces, org, repositories, archive_criteria, notification_content
795795
)
796796

797-
assert repositories_archived == 0
798-
assert issues_created == 5 # noqa: PLR2004
797+
assert repositories_archived == []
798+
assert issues_created == ["repo1", "repo2", "repo3", "repo4", "repo5"] # noqa: PLR2004
799799
assert mock_rest_instance.post.call_count == 5 # noqa: PLR2004
800800
mock_logger_instance.log_info.assert_called_with(
801801
"Skipping repository. Maximum number of notifications reached."
@@ -832,8 +832,8 @@ def test_process_repositories_issue_label_creation(self, mock_rest, mock_logger)
832832
interfaces, org, repositories, archive_criteria, notification_content
833833
)
834834

835-
assert repositories_archived == 0
836-
assert issues_created == 1
835+
assert repositories_archived == []
836+
assert issues_created == ["repo1"]
837837

838838
# Assert that there was 2 post requests for 1 repository
839839
# This means that the label was created and the issue was created
@@ -870,8 +870,8 @@ def test_process_repositories_issue_label_exists(self, mock_rest, mock_logger):
870870
interfaces, org, repositories, archive_criteria, notification_content
871871
)
872872

873-
assert repositories_archived == 0
874-
assert issues_created == 1
873+
assert repositories_archived == []
874+
assert issues_created == ["repo1"]
875875

876876
# Assert that there was 1 post request for 1 repository
877877
# This means that the issue was created but not the label since it already exists
@@ -908,8 +908,8 @@ def test_process_repositories_issue_label_creation_failed(self, mock_rest, mock_
908908
interfaces, org, repositories, archive_criteria, notification_content
909909
)
910910

911-
assert repositories_archived == 0
912-
assert issues_created == 0
911+
assert repositories_archived == []
912+
assert issues_created == []
913913

914914
# Assert that there was 1 post request for 1 repository
915915
# This means that the label creation failed and the issue was not created
@@ -946,8 +946,8 @@ def test_process_repositories_issue_creation_failed(self, mock_rest, mock_logger
946946
interfaces, org, repositories, archive_criteria, notification_content
947947
)
948948

949-
assert repositories_archived == 0
950-
assert issues_created == 0
949+
assert repositories_archived == []
950+
assert issues_created == []
951951

952952
# Assert that there was 1 post request for 1 repository
953953
# This means that the issue creation failed
@@ -981,8 +981,8 @@ def test_process_repositories_archive_failure(self, mock_rest, mock_logger):
981981
interfaces, org, repositories, archive_criteria, notification_content
982982
)
983983

984-
assert repositories_archived == 0
985-
assert issues_created == 0
984+
assert repositories_archived == []
985+
assert issues_created == []
986986
mock_rest_instance.patch.assert_called_once_with(f"/repos/{org}/repo1", {"archived": True})
987987

988988

@@ -1042,7 +1042,7 @@ def test_handler_success( # noqa: PLR0913
10421042
["ArchiveExemption.txt", "ArchiveExemption.md"],
10431043
5,
10441044
)
1045-
mock_process_repositories.return_value = (1, 1)
1045+
mock_process_repositories.return_value = (["Repo1"], ["Repo2"])
10461046

10471047
# Call the handler function
10481048
result = handler({}, {})
@@ -1210,7 +1210,7 @@ def get_dict_value_side_effect(config, key):
12101210
mock_github_interface.return_value = MagicMock()
12111211
mock_get_repositories.return_value = ([{"name": "repo1"}], 1)
12121212
mock_load_archive_rules.return_value = (365, 30, "archive-notice", ["DO_NOT_ARCHIVE"], 5)
1213-
mock_process_repositories.return_value = (1, 2)
1213+
mock_process_repositories.return_value = (["repo1"], ["repo2", "repo3"])
12141214

12151215
result = handler(None, None)
12161216

@@ -1288,7 +1288,7 @@ def get_dict_value_side_effect(config, key):
12881288
mock_github_interface.return_value = MagicMock()
12891289
mock_get_repositories.return_value = ([{"name": "repo1"}], 1)
12901290
mock_load_archive_rules.return_value = (365, 30, "archive-notice", ["DO_NOT_ARCHIVE"], 5)
1291-
mock_process_repositories.return_value = (1, 2)
1291+
mock_process_repositories.return_value = (["repo1"], ["repo2", "repo3"])
12921292

12931293
result = handler(None, None)
12941294

0 commit comments

Comments
 (0)