Skip to content

Commit e6042e2

Browse files
committed
Shorten function names for Unittests
1 parent 51eae09 commit e6042e2

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

mod_ci/controllers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ def start_ci():
858858
message="Cancelling tests as Github Action(s) failed")
859859
elif is_complete:
860860
if payload['workflow_run']['event'] == "pull_request":
861-
# In case of pull request run tests of only if it is still in open state
861+
# In case of pull request run tests only if it is still in an open state
862862
# and user is not blacklisted
863863
for pull_request in repository.pulls.get(state="open"):
864864
if pull_request['head']['sha'] == commit_hash and any(builds.values()):

tests/test_ci/TestControllers.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -712,11 +712,9 @@ def test_webhook_pr_opened(self, mock_request, mock_add_test_entry, mock_github,
712712
mock_blocked.query.filter.assert_called_once_with(mock_blocked.user_id == 'test')
713713
mock_add_test_entry.assert_called_once()
714714

715-
@mock.patch('mod_ci.controllers.GitHub')
716715
@mock.patch('mod_ci.controllers.schedule_test')
717716
@mock.patch('requests.get', side_effect=mock_api_request_github)
718-
def test_webhook_workflow_run_event_requested_action_with_valid_workflow_name(self, mock_request,
719-
mock_schedule_test, mock_github):
717+
def test_webhook_workflow_run_requested_valid_workflow_name(self, mock_request, mock_schedule_test):
720718
"""Test webhook triggered with workflow run event with action requested with a valid workflow name."""
721719
data = {'action': 'requested', 'workflow_run': {
722720
'name': 'Build CCExtractor on Linux', 'head_sha': 'abcd1234'}}
@@ -729,11 +727,11 @@ def test_webhook_workflow_run_event_requested_action_with_valid_workflow_name(se
729727

730728
@mock.patch('mod_ci.controllers.queue_test')
731729
@mock.patch('requests.get', side_effect=mock_api_request_github)
732-
def test_webhook_workflow_run_event_completed_action_successful(self, mock_request, mock_queue_test):
730+
def test_webhook_workflow_run_completed_successful(self, mock_request, mock_queue_test):
733731
"""Test webhook triggered with workflow run event with action completed and status success."""
734732
data = {'action': 'completed',
735733
'workflow_run': {'event': 'push',
736-
'name': 'Build CCExtractor on Linux', 'head_sha': '1',
734+
'name': Workflow_builds.LINUX, 'head_sha': '1',
737735
'head_branch': 'master'}, 'sender': {'login': 'test_owner'}}
738736
fakedata = {'workflow_runs': [
739737
{'head_sha': '1', 'status': 'completed',
@@ -766,7 +764,7 @@ def repos(self, *args):
766764

767765
@mock.patch('mod_ci.controllers.deschedule_test')
768766
@mock.patch('requests.get', side_effect=mock_api_request_github)
769-
def test_webhook_workflow_run_event_completed_action_failure(self, mock_request, mock_deschedule_test):
767+
def test_webhook_workflow_run_completed_failure(self, mock_request, mock_deschedule_test):
770768
"""Test webhook triggered with workflow run event with action completed and status failure."""
771769
data = {'action': 'completed',
772770
'workflow_run': {'event': 'push',
@@ -799,11 +797,9 @@ def repos(self, *args):
799797
data=json.dumps(data), headers=self.generate_header(data, 'workflow_run'))
800798
mock_deschedule_test.assert_called_once()
801799

802-
@mock.patch('mod_ci.controllers.GitHub')
803800
@mock.patch('mod_ci.controllers.schedule_test')
804801
@mock.patch('requests.get', side_effect=mock_api_request_github)
805-
def test_webhook_workflow_run_requested_action_with_invalid_workflow_name(self, mock_request,
806-
mock_schedule_test, mock_github):
802+
def test_webhook_workflow_run_requested_invalid_workflow_name(self, mock_request, mock_schedule_test):
807803
"""Test webhook triggered with workflow run event with an invalid action."""
808804
data = {'action': 'requested', 'workflow_run': {
809805
'name': 'Invalid', 'head_sha': 'abcd1234'}}
@@ -843,8 +839,7 @@ def test_webhook_with_invalid_ci_signature(self, mock_github, mock_warning):
843839
@mock.patch('mod_ci.controllers.BlockedUsers')
844840
@mock.patch('mod_ci.controllers.queue_test')
845841
@mock.patch('requests.get', side_effect=mock_api_request_github)
846-
def test_webhook_workflow_run_event_completed_action_successful_pull_request(self, mock_request,
847-
mock_queue_test, mock_blocked):
842+
def test_webhook_workflow_run_completed_successful_pr(self, mock_request, mock_queue_test, mock_blocked):
848843
"""Test webhook triggered with workflow run event with action completed and status success for pull request."""
849844
data = {'action': 'completed',
850845
'workflow_run': {'event': 'pull_request',

0 commit comments

Comments
 (0)