Skip to content

Commit 103d07f

Browse files
Modify fixtures to support multiple content views by default (SatelliteQE#20379)
* Support multiple content views by default This PR makes changes to two test modules and two fixture modules to support the changes from Katello/katello#11576. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent db8f1a1 commit 103d07f

File tree

4 files changed

+63
-148
lines changed

4 files changed

+63
-148
lines changed

pytest_fixtures/component/activationkey.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,12 @@ def module_ak_with_synced_repo(module_sca_manifest_org, module_target_sat):
7575
'organization-id': module_sca_manifest_org.id,
7676
}
7777
)
78+
79+
80+
@pytest.fixture(scope='module')
81+
def module_default_ak(module_target_sat, module_org):
82+
return module_target_sat.api.ActivationKey(
83+
organization=module_org,
84+
content_view=module_org.default_content_view.id,
85+
environment=module_org.library.id,
86+
).create()

pytest_fixtures/component/contentview.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -78,31 +78,3 @@ def module_cv_repo(module_org, module_repository, module_lce, module_target_sat)
7878
content_view = content_view.read()
7979
content_view.version[0].promote(data={'environment_ids': module_lce.id, 'force': False})
8080
return content_view
81-
82-
83-
@pytest.fixture(scope='session')
84-
def session_multicv_sat(session_satellite_host):
85-
"""Satellite with multi-CV enabled"""
86-
session_satellite_host.update_setting('allow_multiple_content_views', 'True')
87-
return session_satellite_host
88-
89-
90-
@pytest.fixture(scope='session')
91-
def session_multicv_org(session_multicv_sat):
92-
return session_multicv_sat.api.Organization().create()
93-
94-
95-
@pytest.fixture(scope='session')
96-
def session_multicv_default_ak(session_multicv_sat, session_multicv_org):
97-
return session_multicv_sat.api.ActivationKey(
98-
organization=session_multicv_org,
99-
content_view=session_multicv_org.default_content_view.id,
100-
environment=session_multicv_org.library.id,
101-
).create()
102-
103-
104-
@pytest.fixture(scope='session')
105-
def session_multicv_lce(session_multicv_sat, session_multicv_org):
106-
return session_multicv_sat.api.LifecycleEnvironment(
107-
organization=session_multicv_org,
108-
).create()

tests/foreman/cli/test_activationkey.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ def test_positive_invalid_release_version(module_sca_manifest_org, module_target
14931493

14941494

14951495
# -------------------------- MULTI-CV SCENARIOS -------------------------
1496-
def test_positive_create_ak_with_multi_cv_envs(session_multicv_sat, session_multicv_org):
1496+
def test_positive_create_ak_with_multi_cv_envs(module_target_sat, module_org):
14971497
"""Verify that multiple content view environments can be assigned during activation key creation
14981498
14991499
:id: 263a6c90-88bf-4888-b1b9-172751a609f3
@@ -1510,14 +1510,13 @@ def test_positive_create_ak_with_multi_cv_envs(session_multicv_sat, session_mult
15101510
"""
15111511
# Create two lifecycle environments
15121512
lces_list = [
1513-
session_multicv_sat.api.LifecycleEnvironment(organization=session_multicv_org).create()
1513+
module_target_sat.api.LifecycleEnvironment(organization=module_org).create()
15141514
for i in range(2)
15151515
]
15161516
lce1, lce2 = lces_list
15171517
# Create two content views
15181518
cvs_list = [
1519-
session_multicv_sat.api.ContentView(organization=session_multicv_org).create()
1520-
for i in range(2)
1519+
module_target_sat.api.ContentView(organization=module_org).create() for i in range(2)
15211520
]
15221521
for i in range(2):
15231522
cvs_list[i].publish()
@@ -1528,9 +1527,9 @@ def test_positive_create_ak_with_multi_cv_envs(session_multicv_sat, session_mult
15281527
# Create an activation key with created content view environments
15291528
ak_name = gen_string('alpha')
15301529
cv_envs = f'{lce1.name}/{cv1.name},{lce2.name}/{cv2.name}'
1531-
ak = session_multicv_sat.cli.ActivationKey.create(
1530+
ak = module_target_sat.cli.ActivationKey.create(
15321531
{
1533-
'organization-id': session_multicv_org.id,
1532+
'organization-id': module_org.id,
15341533
'content-view-environments': cv_envs,
15351534
'name': ak_name,
15361535
}
@@ -1541,7 +1540,7 @@ def test_positive_create_ak_with_multi_cv_envs(session_multicv_sat, session_mult
15411540

15421541

15431542
def test_positive_multi_cv_info_and_remove_all_cv_envs(
1544-
session_multicv_sat, session_multicv_org, session_multicv_default_ak
1543+
module_target_sat, module_org, module_default_ak
15451544
):
15461545
"""Verify that multi content view environment details displays into hammer activation-key info commands output, and
15471546
also remove all content view environments & verify output
@@ -1563,14 +1562,13 @@ def test_positive_multi_cv_info_and_remove_all_cv_envs(
15631562
"""
15641563
# Create two lifecycle environments
15651564
lces_list = [
1566-
session_multicv_sat.api.LifecycleEnvironment(organization=session_multicv_org).create()
1565+
module_target_sat.api.LifecycleEnvironment(organization=module_org).create()
15671566
for i in range(2)
15681567
]
15691568
lce1, lce2 = lces_list
15701569
# Create two content views
15711570
cvs_list = [
1572-
session_multicv_sat.api.ContentView(organization=session_multicv_org).create()
1573-
for i in range(2)
1571+
module_target_sat.api.ContentView(organization=module_org).create() for i in range(2)
15741572
]
15751573
for i in range(2):
15761574
cvs_list[i].publish()
@@ -1579,36 +1577,36 @@ def test_positive_multi_cv_info_and_remove_all_cv_envs(
15791577
cv1, cv2 = cvs_list
15801578

15811579
# Update ak with multiple content view environments
1582-
ak = session_multicv_default_ak
1580+
ak = module_default_ak
15831581
cv_envs = f'{lce1.name}/{cv1.name},{lce2.name}/{cv2.name}'
1584-
ak_info = session_multicv_sat.cli.ActivationKey.info({'id': ak.id})
1582+
ak_info = module_target_sat.cli.ActivationKey.info({'id': ak.id})
15851583
assert ak_info['multi-content-view-environment'] == 'no'
15861584
assert ak_info['content-view-environment-labels'] == 'Library'
15871585

1588-
ret_val = session_multicv_sat.cli.ActivationKey.update(
1586+
ret_val = module_target_sat.cli.ActivationKey.update(
15891587
{
15901588
'id': ak.id,
1591-
'organization-id': session_multicv_org.id,
1589+
'organization-id': module_org.id,
15921590
'content-view-environments': cv_envs,
15931591
}
15941592
)
15951593
assert ret_val[0]['message'] == 'Activation key updated.'
15961594

15971595
# Verify ak info displays 'Multi Content View Environment' and 'Content View Environments'
1598-
ak_info = session_multicv_sat.cli.ActivationKey.info({'id': ak.id})
1596+
ak_info = module_target_sat.cli.ActivationKey.info({'id': ak.id})
15991597
assert ak_info['multi-content-view-environment'] == 'yes'
16001598
assert ak_info['content-view-environment-labels'] == cv_envs
16011599

16021600
# Remove all content view environments from the activation key
1603-
session_multicv_sat.cli.ActivationKey.update(
1601+
module_target_sat.cli.ActivationKey.update(
16041602
{
16051603
'id': ak.id,
1606-
'organization-id': session_multicv_org.id,
1604+
'organization-id': module_org.id,
16071605
'content-view-environments': '',
16081606
}
16091607
)
16101608
# Verify ak info doesn't display any 'Content View Environments'
1611-
ak_info = session_multicv_sat.cli.ActivationKey.info({'id': ak.id})
1609+
ak_info = module_target_sat.cli.ActivationKey.info({'id': ak.id})
16121610
assert ak_info['multi-content-view-environment'] == 'no'
16131611
assert ak_info['content-view-environment-labels'] == {}
16141612

0 commit comments

Comments
 (0)