From 71378d92e029d02cd5383621229a156a04bc19e6 Mon Sep 17 00:00:00 2001 From: Tomas Hrcka Date: Aug 04 2020 11:27:37 +0000 Subject: Tests Signed-off-by: Tomas Hrcka --- diff --git a/.gitignore b/.gitignore index 34643c6..4eec573 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ dist/ .coverage .vscode/ .pytest_cache/ +venv/ *~ diff --git a/fedscm_admin/pdc.py b/fedscm_admin/pdc.py index c10b307..6d89b99 100644 --- a/fedscm_admin/pdc.py +++ b/fedscm_admin/pdc.py @@ -137,7 +137,7 @@ def new_branch(global_component, branch, branch_type): branch_type, global_component, branch)) existing_branch = get_branch(global_component, branch, branch_type) if existing_branch is not None: - if existing_branch['slas']: + if existing_branch.get('slas', False): raise ValidationError( 'The PDC branch already exists and has SLAs tied to it') else: diff --git a/fedscm_admin/utils.py b/fedscm_admin/utils.py index 0b74295..e44c534 100644 --- a/fedscm_admin/utils.py +++ b/fedscm_admin/utils.py @@ -246,7 +246,6 @@ def process_ticket(issue, force=False, auto_approve=False): issue_body['sls'] = get_standard_branch_sla_dict(branch) except ValidationError: # pragma: no cover pass - if 'branch' in issue_body and 'namespace' in issue_body: branch = issue_body['branch'] ns = issue_body['namespace'] diff --git a/tests/test_admin.py b/tests/test_admin.py index 870fcef..c107eea 100644 --- a/tests/test_admin.py +++ b/tests/test_admin.py @@ -172,7 +172,7 @@ class FedScmAdmin(TestCase): 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'), + 'master', 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), @@ -191,14 +191,7 @@ class FedScmAdmin(TestCase): 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 result.output.count('- Closing Pagure issue 2') == 1 assert self.mock_git_obj.clone_repo.call_count == 0 @patch('fedscm_admin.utils.verify_slas', return_value=None) @@ -215,7 +208,7 @@ class FedScmAdmin(TestCase): 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'), + 'master', 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), @@ -234,14 +227,6 @@ class FedScmAdmin(TestCase): 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)