From b4a38c707a317db5e00d8368d7e4a1979d481ec2 Mon Sep 17 00:00:00 2001 From: vijaysawant Date: Fri, 8 Mar 2024 17:25:46 +0530 Subject: [PATCH] validate that cv warning to force promote --- tests/foreman/cli/test_contentview.py | 56 +++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/foreman/cli/test_contentview.py b/tests/foreman/cli/test_contentview.py index 0b4ee4041ef..e9215295394 100644 --- a/tests/foreman/cli/test_contentview.py +++ b/tests/foreman/cli/test_contentview.py @@ -4065,6 +4065,62 @@ def test_version_info_by_lce(self, module_org, module_target_sat): ) assert content_view['version'] == '1.0' + def test_positive_validate_force_promote_warning(self, target_sat, function_org, default_lce): + """Test cv promote shows warning of 'force promotion' for out of sequence LCE + + :id: 1bfb76be-ab40-48b4-b5a3-428a2a9ab99b + + :steps: + 1. Create an environment path ex- Library >> Test >> Preprod + 2. Create a CV and publish > promote to Test + 3. Promote version 1.0 to Preprod (sequencial in environment path) + 4. Publish version 2.0 + 5. Try to promote 2.0 on to Preprod + + :expectedresults: + 1. After step 4, version 1.0 in 'Test' and 2.0 in 'Library' + 2. After step 5, we will get warning, 'Cannot promote environment out of sequence. Use force to bypass restriction' + + :CaseImportance: High + + :BZ: 2125728 + + """ + # 1. Create an environment path ex- Library >> Test >> Preprod >> Prod + lce_test = target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': function_org.id} + ) + lce_preprod = target_sat.cli_factory.make_lifecycle_environment( + {'organization-id': function_org.id, 'prior': lce_test['name']} + ) + + # 2. Create a CV and publish > promote to Test + cv = target_sat.cli_factory.make_content_view({'organization-id': function_org.id}) + target_sat.cli.ContentView.publish({'id': cv['id']}) + cv_version_1 = target_sat.cli.ContentView.info({'id': cv['id']})['versions'][0] + target_sat.cli.ContentView.version_promote( + {'id': cv_version_1['id'], 'to-lifecycle-environment-id': lce_test['id']} + ) + + # 3. Promote version 1.0 to preprod + target_sat.cli.ContentView.version_promote( + {'id': cv_version_1['id'], 'to-lifecycle-environment-id': lce_preprod['id']} + ) + + # 4. Publish version 2.0 + target_sat.cli.ContentView.publish({'id': cv['id']}) + cv_version_2 = target_sat.cli.ContentView.info({'id': cv['id']})['versions'][0] + + # 5. Try to promote 2.0 on to Preprod + with pytest.raises(CLIReturnCodeError) as error: + target_sat.cli.ContentView.version_promote( + {'id': cv_version_2['id'], 'to-lifecycle-environment-id': lce_preprod['id']} + ) + assert ( + 'Cannot promote environment out of sequence. Use force to bypass restriction' + in error.value.stderr + ) + class TestContentViewFileRepo: """Specific tests for Content Views with File Repositories containing