| |
@@ -160,6 +160,92 @@
|
| |
|
| |
@patch('fedscm_admin.utils.verify_slas', return_value=None)
|
| |
@patch('fedscm_admin.request_utils.retry_session')
|
| |
+ def test_fedscm_admin_process_modules(self, mock_retry_session, mock_slas):
|
| |
+ """
|
| |
+ Tests fedscm-admin with the option "process" on a new repo request
|
| |
+ for a module
|
| |
+ """
|
| |
+ from fedscm_admin.fedscm_admin import cli as fedscm_admin_cli
|
| |
+ mock_session = Mock()
|
| |
+ mock_rv = Mock()
|
| |
+ mock_rv.ok = True
|
| |
+ mock_rv.json.return_value = {}
|
| |
+ mock_session.get.side_effect = [
|
| |
+ mock_values.get_mock_issue_rv(
|
| |
+ 'abc', sla={'security_fixes': '2025-06-01'}, namespace='modules'),
|
| |
+ mock_values.get_mock_users_query('akhairna'),
|
| |
+ mock_values.get_mock_pagure_project(exists=False),
|
| |
+ mock_values.get_mock_pdc_branch('abc', exists=False),
|
| |
+ mock_values.get_mock_pdc_branch('master', exists=False),
|
| |
+ mock_values.get_mock_pdc_global_component(exists=True),
|
| |
+ mock_values.get_mock_pdc_branch('abc', exists=False),
|
| |
+ mock_values.get_mock_pdc_branch('master', exists=False),
|
| |
+ mock_values.get_mock_pagure_git_urls()
|
| |
+ ]
|
| |
+ mock_session.post.return_value = mock_rv
|
| |
+ mock_session.patch.return_value = mock_rv
|
| |
+ mock_retry_session.return_value = mock_session
|
| |
+ runner = CliRunner()
|
| |
+ result = runner.invoke(
|
| |
+ fedscm_admin_cli, ['process', '2'],
|
| |
+ input='mprahl\n12345\nmprahl\n12345\napprove\nn\n')
|
| |
+ assert result.exit_code == 0
|
| |
+ assert result.output.count('- Adding comment to Pagure issue') == 1
|
| |
+ assert result.output.count('- Adding comment to rhbz#') == 1
|
| |
+ outputs = [
|
| |
+ 'New Repo for "rpms/nethack"',
|
| |
+ 'The Pagure repository was created',
|
| |
+ 'You may commit to the branch "abc" in about 10 minutes.'
|
| |
+ ]
|
| |
+ for output in outputs:
|
| |
+ assert output in result.output
|
| |
+ assert self.mock_git_obj.clone_repo.call_count == 0
|
| |
+
|
| |
+ @patch('fedscm_admin.utils.verify_slas', return_value=None)
|
| |
+ @patch('fedscm_admin.request_utils.retry_session')
|
| |
+ def test_fedscm_admin_process_tests(self, mock_retry_session, mock_slas):
|
| |
+ """
|
| |
+ Tests fedscm-admin with the option "process" on a new repo request
|
| |
+ for a repo for shared tests
|
| |
+ """
|
| |
+ from fedscm_admin.fedscm_admin import cli as fedscm_admin_cli
|
| |
+ mock_session = Mock()
|
| |
+ mock_rv = Mock()
|
| |
+ mock_rv.ok = True
|
| |
+ mock_rv.json.return_value = {}
|
| |
+ mock_session.get.side_effect = [
|
| |
+ mock_values.get_mock_issue_rv(
|
| |
+ 'abc', sla={'security_fixes': '2025-06-01'}, namespace='tests'),
|
| |
+ mock_values.get_mock_users_query('akhairna'),
|
| |
+ mock_values.get_mock_pagure_project(exists=False),
|
| |
+ mock_values.get_mock_pdc_branch('abc', exists=False),
|
| |
+ mock_values.get_mock_pdc_branch('master', exists=False),
|
| |
+ mock_values.get_mock_pdc_global_component(exists=True),
|
| |
+ mock_values.get_mock_pdc_branch('abc', exists=False),
|
| |
+ mock_values.get_mock_pdc_branch('master', exists=False),
|
| |
+ mock_values.get_mock_pagure_git_urls()
|
| |
+ ]
|
| |
+ mock_session.post.return_value = mock_rv
|
| |
+ mock_session.patch.return_value = mock_rv
|
| |
+ mock_retry_session.return_value = mock_session
|
| |
+ runner = CliRunner()
|
| |
+ result = runner.invoke(
|
| |
+ fedscm_admin_cli, ['process', '2'],
|
| |
+ input='mprahl\n12345\nmprahl\n12345\napprove\nn\n')
|
| |
+ assert result.exit_code == 0
|
| |
+ assert result.output.count('- Adding comment to Pagure issue') == 1
|
| |
+ assert result.output.count('- Adding comment to rhbz#') == 1
|
| |
+ outputs = [
|
| |
+ 'New Repo for "rpms/nethack"',
|
| |
+ 'The Pagure repository was created',
|
| |
+ 'You may commit to the branch "abc" in about 10 minutes.'
|
| |
+ ]
|
| |
+ for output in outputs:
|
| |
+ assert output in result.output
|
| |
+ assert self.mock_git_obj.clone_repo.call_count == 0
|
| |
+
|
| |
+ @patch('fedscm_admin.utils.verify_slas', return_value=None)
|
| |
+ @patch('fedscm_admin.request_utils.retry_session')
|
| |
def test_fedscm_admin_process_force(
|
| |
self, mock_retry_session, mock_slas):
|
| |
"""
|
| |
Introduce two new tests for modules and test namespace.
Actual code coverage has increased 0.98%