From bf318d79b153b57e26e14d44e918eb72db7b22e3 Mon Sep 17 00:00:00 2001 From: David Moore Date: Thu, 17 Oct 2024 08:51:00 -0400 Subject: [PATCH] fixup --- tests/foreman/ui/test_contentview.py | 92 +++++++++++++++++++++------- 1 file changed, 69 insertions(+), 23 deletions(-) diff --git a/tests/foreman/ui/test_contentview.py b/tests/foreman/ui/test_contentview.py index d15b2b41b47..8184bd443ba 100644 --- a/tests/foreman/ui/test_contentview.py +++ b/tests/foreman/ui/test_contentview.py @@ -13,8 +13,10 @@ """ from fauxfactory import gen_string +from time import sleep import pytest +from airgun.exceptions import NoSuchElementException from robottelo.config import settings from robottelo.constants import ( FAKE_FILE_NEW_NAME, @@ -168,17 +170,16 @@ def test_positive_delete_cv_promoted_to_multi_env( :id: f16f2db5-7f5b-4ebb-863e-6c18ff745ce4 :steps: - 1. Create a yum repo on satellite - 2. Create a content view and add the repository - 3. Publish the content view, creates "Version 1.0" - 4. Promote the "Version 1.0" to multiple environments Library -> DEV - 5. Delete the promoted content view version - 6. Publish and promote a new "Version 1.0" to multiple environments - 7. Delete the content view - - :expectedresults: - 5. Deleting the promoted CVV, removed the CV from multiple environments. - 7. Deleting the CV with promoted CVV, removed the CV from multiple environments. + 1. Create a yum repository on satellite and add to a new content view. + 2. Publish the content view, creates "Version 1.0". + 3. Promote the "Version 1.0" to multiple environments, Library -> DEV. + 4. Delete the promoted version, verify removed from environments. + 5. Publish and promote a new "Version 1.0" to multiple environments. + 6. Delete the entire content view, verify removed from environments. + + :expectedresults: The deleted CV and CVV do not exist, + 4. Deleting the single promoted CVV, removed the CV from multiple environments. + 6. Deleting the entire CV containing promoted CVV, removed the CV from multiple environments. :CaseImportance: High """ @@ -198,25 +199,70 @@ def test_positive_delete_cv_promoted_to_multi_env( f'Latest version for CV {cv["name"]}: {cv_info["Latest version"]},' f' does not match expected: {VERSION}.' ) - cvv_values = session.contentview_new.read_cv(cv['name'], VERSION) - assert lce['name'] in cvv_values['Environments'] + cvv_values = session.contentview_new.read_cv(entity_name=cv['name'], version_name=VERSION) + #assert all(['Library', lce['name']]) in cvv_values['Environments'] # read UI info from repo table in CVV - repo_info = session.contentview_new.read_version_table(cv['name'], VERSION, 'repositories') + repo_info = session.contentview_new.read_version_table( + entity_name=cv['name'], + version=VERSION, + tab_name='repositories', + ) assert ( repo_name == repo_info[0]['Name'] - ), 'Repositories tab for CVV shows incorrect repo name.' + ), 'Repositories tab for CVV shows incorrect repository.' # read UI info from LCE of the CVV lce_values = session.lifecycleenvironment.read(lce['name']) assert len(lce_values['content_views']['resources']) == 1 assert ( cv['name'] == lce_values['content_views']['resources'][0]['Name'] - ), f'Environment {lce["name"]}, does not show expected CVV {cv["name"]}, contained within.' - # delete the CVV, try searching for it, then delete the ContentView itself - session.contentview_new.click_version_dropdown(cv['name'], VERSION, 'Delete') + ), f'Environment {lce["name"]}, does not show expected CV {cv["name"]}, contained within.' + + # Delete the promoted CVV + session.contentview_new.delete_version(entity_name=cv['name'], version=VERSION) + with pytest.raises(NoSuchElementException) as err: + # CVV is no longer visible in Versions table + session.contentview_new.read_cv(entity_name=cv['name'], version_name=VERSION) + # the CV's name is not associated to LCEs anymore + lce_values = session.lifecycleenvironment.read(lce['name']) + assert cv['name'] not in str(lce_values['content_views']['resources']) + lce_values = session.lifecycleenvironment.read('Library') + assert cv['name'] not in str(lce_values['content_views']['resources']) + + # publish & promote, a new Version 1.0, to test deleting entire CV with CVV in LCEs. + # UI methods aren't needed, as this case does not test publish or promote + cvv_id = target_sat.api.ContentView(id=cv['id']).publish()['input']['content_view_version_id'] + waiter = target_sat.cli.ContentView.version_promote( + { + 'id': cvv_id, + 'organization-id': module_org.id, + 'to-lifecycle-environment-id': lce['id'], + 'async': False, + } + ) + #at = target_sat.api.ContentViewVersion(id=cvv_id).promote(data={'environment_ids': lce.id}) + #cvv_values = session.contentview_new.read_cv(entity_name=cv['name'], version_name=VERSION) + # the promotion associated CV and LCE again + assert 'Library' in str(cvv_values['Environments']) + assert lce['name'] in str(cvv_values['Environments']) + lce_values = session.lifecycleenvironment.read(lce['name']) + assert cv['name'] == lce_values['content_views']['resources'][0]['Name'] + + # delete the whole content view + session.contentview_new.delete(cv['name']) + #breakpoint() + cv_info = session.contentview_new.search(cv['name']) + assert len(cv_info) == 0 # session.contentview.remove_version(cv['name'], VERSION, False, [ENVIRONMENT, lce['name']]) - cv = session.contentview_new.search(cv['name'], VERSION)[0] - """assert lce['name'] not in cv['Environments'] - assert 'Library' not in cv['Environments']""" - session.contentview.delete(cv['name']) + #cv = session.contentview_new.read_cv(cv['name'], VERSION) + #breakpoint() + # the deleted CV's name is not found in LCEs + #assert any('Library', lce['name']) not in cvv_values['Environments'] + #assert 'Library' not in cv['Environments'] lce_values = session.lifecycleenvironment.read(lce['name']) - assert cv not in lce_values['content_views']['resources'] + assert cv['name'] not in str(lce_values['content_views']['resources']) + lce_values = session.lifecycleenvironment.read('Library') + assert cv['name'] not in str(lce_values['content_views']['resources']) + + # ensure the deleted CV and CVV are not present + #target_sat.api.ContentView(id=cv['id']).read() + #target_sat.api.ContentViewVersion(id=cvv_values['id]).read()