Skip to content

Commit

Permalink
CV_old upgrade case brought into new UI
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed Oct 17, 2024
1 parent 8cfa771 commit 494b470
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 47 deletions.
110 changes: 109 additions & 1 deletion tests/foreman/ui/test_contentview.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@
"""

from fauxfactory import gen_string
from time import sleep
import pytest

from robottelo.constants import FAKE_FILE_NEW_NAME, REPOS, DataFile
from airgun.exceptions import NoSuchElementException
from robottelo.config import settings
from robottelo.constants import (
FAKE_FILE_NEW_NAME,
REPOS,
DataFile,
)


@pytest.mark.tier2
Expand Down Expand Up @@ -147,3 +154,104 @@ def test_file_cv_display(session, target_sat, module_org, module_product):
file_values = session.file.read_cv_table(FAKE_FILE_NEW_NAME)
assert len(file_values) == 1
assert file_values[0]['Name'] == cv.name


# @pytest.mark.upgrade
@pytest.mark.tier2
def test_positive_delete_cv_promoted_to_multi_env(
session,
module_target_sat,
module_org,
target_sat,
):
"""Delete the published content view version promoted to multiple
environments. Delete the entire content view, with a promoted version to
multiple environments.
:id: f16f2db5-7f5b-4ebb-863e-6c18ff745ce4
:steps:
1. Create and sync yum repository on satellite, add to a new content view.
2. Publish the content view, '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
"""
VERSION = 'Version 1.0'
repo = target_sat.cli_factory.RepositoryCollection(
repositories=[target_sat.cli_factory.YumRepository(url=settings.repos.yum_0.url)]
)
repo.setup(module_org.id)
cv, lce = repo.setup_content_view(module_org.id)

with target_sat.ui_session() as session:
session.organization.select(org_name=module_org.name)
cv_info = session.contentview_new.search(cv['name'])[0]
assert cv_info['Latest version'] == VERSION, (
f'Latest version for CV {cv["name"]}: {cv_info["Latest version"]},'
f' does not match expected: {VERSION}.'
)
# Environment's names are found in CVV info
cvv_values = session.contentview_new.read_cv(entity_name=cv['name'], version_name=VERSION)
assert 'Library' in str(cvv_values['Environments'])
assert lce['name'] in str(cvv_values['Environments'])
# CV name is found in both environment's info
lce_values = session.lifecycleenvironment.read(lce['name'])
assert cv['name'] == lce_values['content_views']['resources'][0]['Name']
library_values = session.lifecycleenvironment.read('Library')
assert cv['name'] == library_values['content_views']['resources'][0]['Name']

# read UI info from the non-Library environment
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 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 found in CV's Versions tab
session.contentview_new.read_cv(entity_name=cv['name'], version_name=VERSION)
# the CV's name is not associated to either environment anymore
lce_values = session.lifecycleenvironment.read(lce['name'])
assert cv['name'] not in str(lce_values['content_views']['resources'])
library_values = session.lifecycleenvironment.read('Library')
assert cv['name'] not in str(library_values['content_views']['resources'])

# publish & promote, a new Version 1.0, to test deleting entire CV with a 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,
}
)
# promotion associated CV to both environments 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']
library_values = session.lifecycleenvironment.read('Library')
assert cv['name'] == library_values['content_views']['resources'][0]['Name']

# delete the whole content view, search for its name to check
session.contentview_new.delete(cv['name'])
cv_info = session.contentview_new.search(cv['name'])
assert cv_info is None
# the deleted CV's name is not found in either environment
lce_values = session.lifecycleenvironment.read(lce['name'])
assert cv['name'] not in str(lce_values['content_views']['resources'])
library_values = session.lifecycleenvironment.read('Library')
assert cv['name'] not in str(library_values['content_views']['resources'])
breakpoint()
46 changes: 0 additions & 46 deletions tests/foreman/ui/test_contentview_old.py
Original file line number Diff line number Diff line change
Expand Up @@ -1518,52 +1518,6 @@ def test_positive_remove_cv_version_from_env(
assert all(item in cvv['Environments'] for item in [ENVIRONMENT, dev_lce.name, qe_lce.name])


@pytest.mark.upgrade
@pytest.mark.tier2
@pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url')
def test_positive_delete_cv_promoted_to_multi_env(
session, module_target_sat, module_org, target_sat
):
"""Delete published content view with version promoted to multiple
environments
:id: f16f2db5-7f5b-4ebb-863e-6c18ff745ce4
:steps:
1. Create a content view
2. Add a yum repo to the content view
3. Publish the content view
4. Promote the content view to multiple environment Library -> DEV
5. Disassociate content view from promoted environment
6. Delete the content view.
:expectedresults: The content view doesn't exists.
:CaseImportance:High
"""
repo = target_sat.cli_factory.RepositoryCollection(
repositories=[target_sat.cli_factory.YumRepository(url=settings.repos.yum_0.url)]
)
repo.setup(module_org.id)
cv, lce = repo.setup_content_view(module_org.id)
repo_name = repo.repos_info[0]['name']
with session:
cvv = session.contentview.read_version(cv['name'], VERSION)
assert repo_name == cvv['yum_repositories']['table'][0]['Name']
cvv = session.contentview.search_version(cv['name'], VERSION)[0]
assert lce['name'] in cvv['Environments']
lce_values = session.lifecycleenvironment.read(lce['name'])
assert len(lce_values['content_views']['resources']) == 1
assert lce_values['content_views']['resources'][0]['Name'] == cv['name']
session.contentview.remove_version(cv['name'], VERSION, False, [ENVIRONMENT, lce['name']])
cvv = session.contentview.search_version(cv['name'], VERSION)[0]
assert lce['name'] not in cvv['Environments']
session.contentview.delete(cv['name'])
lce_values = session.lifecycleenvironment.read(lce['name'])
assert cv not in lce_values['content_views']['resources']


@pytest.mark.tier2
@pytest.mark.upgrade
def test_positive_delete_composite_version(session, module_target_sat, module_org, target_sat):
Expand Down

0 comments on commit 494b470

Please sign in to comment.