Skip to content

Commit

Permalink
[6.15.z] [CV Eval] Test for CV Eval/BZ (#15626)
Browse files Browse the repository at this point in the history
[CV Eval] Test for CV Eval/BZ (#15519)

* Test for CV Eval/BZ

* Apply suggestions from code review

Co-authored-by: vsedmik <[email protected]>

* Fix docstring

---------

Co-authored-by: vsedmik <[email protected]>
(cherry picked from commit 9e40aa9)

Co-authored-by: Samuel Bible <[email protected]>
  • Loading branch information
Satellite-QE and sambible authored Jul 11, 2024
1 parent 3f4b8ea commit d3e6bec
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
7 changes: 7 additions & 0 deletions robottelo/cli/contentview.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
info Show a content view
list List content views
publish Publish a content view
purge Delete old versions of a content view
remove Remove versions and/or environments from a
content view and reassign systems and keys
remove-from-environment Remove a content view from an environment
Expand Down Expand Up @@ -113,6 +114,12 @@ def publish(cls, options, timeout=1500000):
cls.command_sub = 'publish'
return cls.execute(cls._construct_command(options), ignore_stderr=True, timeout=timeout)

@classmethod
def purge(cls, options, timeout='25m'):
"""Purges old versions of content-view. Defaults to keeping 3"""
cls.command_sub = 'purge'
return cls.execute(cls._construct_command(options), ignore_stderr=True, timeout=timeout)

@classmethod
def version_info(cls, options, output_format=None):
"""Provides version info related to content-view's version."""
Expand Down
41 changes: 41 additions & 0 deletions tests/foreman/cli/test_contentview.py
Original file line number Diff line number Diff line change
Expand Up @@ -3132,6 +3132,47 @@ def test_show_all_repo_ids(self, module_org, module_product, module_target_sat):
list_info = module_target_sat.cli.ContentView.list({'name': cv.name})
assert set(list_info[0]['repository-ids'].split(', ')) == set(id_list)

@pytest.mark.tier2
def test_cv_version_purge(self, module_org, module_target_sat):
"""Hammer content-view purge correctly purges CV Versions, instead
of just up to the per page value
:id: c2db24cd-946a-4cb6-828d-0e0f38b8ef00
:steps:
1. Create a CV
2. Publish the CV 50 times
3. Run hammer content-view purge --id <cv.id>
:expectedresults: Hammer should purge all but 3 old versions, not just up to the per page value
:Verifies: SAT-15185
:customerscenario: true
"""
content_view = module_target_sat.cli_factory.make_content_view(
{'organization-id': module_org.id}
)
cv_count = 50
for _ in range(cv_count):
module_target_sat.cli.ContentView.publish({'id': content_view['id']})
cvv = module_target_sat.cli.ContentView.version_list(
{'content-view-id': content_view['id']}
)
assert len(cvv) == cv_count
response = module_target_sat.cli.ContentView.purge({'id': content_view['id']})
assert all(
[
f"Version '{v+1}.0' of content view '{content_view.name}' deleted." in response
for v in range(cv_count - 4)
]
)
# Check that the correct number of Versions were purged.
cvv = module_target_sat.cli.ContentView.version_list(
{'content-view-id': content_view['id']}
)
assert len(cvv) == 4

def test_positive_validate_force_promote_warning(self, target_sat, function_org):
"""Test cv promote shows warning of 'force promotion' for out of sequence LCE
Expand Down

0 comments on commit d3e6bec

Please sign in to comment.