Skip to content

Commit

Permalink
[RFE] Should not be able to publish the content-view, while repositor…
Browse files Browse the repository at this point in the history
…y sync in-progress.
  • Loading branch information
damoore044 committed Apr 8, 2024
1 parent f1799c9 commit dac8623
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/foreman/api/test_contentview.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
:CaseImportance: High
"""
from datetime import datetime, timedelta
import random

from fauxfactory import gen_integer, gen_string, gen_utf8
Expand Down Expand Up @@ -532,6 +533,46 @@ def test_positive_add_to_composite(self, content_view, module_org, module_target
# composite CV → CV version → CV == CV
assert composite_cv.component[0].read().content_view.id == content_view.id

@pytest.mark.tier2
def test_negative_publish_during_repo_sync(self, content_view, module_org, module_target_sat):
"""Attempt to publish a new version of the content-view,
while an associated repository is being synced.
:id: c272fff7-a679-4844-a261-80830cdd5694
:expectedresults: User cannot publish during repository sync.
:CaseImportance: High
"""
# add repository to content-view
content_view.repository = [self.yum_repo]
content_view.update(['repository'])
content_view = content_view.read()
existing_versions = content_view.version
timestamp = (datetime.utcnow() - timedelta(seconds=1)).strftime('%Y-%m-%d %H:%M')

# perform async repository sync, while still in progress-
# attempt to publish a new version of the content view.
repo_task_id = self.yum_repo.sync(synchronous=False)['id']
with pytest.raises(HTTPError) as InternalServerError:
content_view.publish()
assert str(content_view.id) in str(InternalServerError)

# search for failed publish task
task_action = 'Actions::Katello::ContentView::Publish'
task_search = module_target_sat.api.ForemanTask().search(
query={'search': f'{task_action} and started_at >= "{timestamp}"'}
)
assert len(task_search) == 1
task_id = task_search[0].id
# task failed for expected reason
task = module_target_sat.api.ForemanTask(id=task_id).poll(must_succeed=False)
assert task['result'] == 'error'
assert len(task['humanized']['errors']) == 1
assert repo_task_id in task['humanized']['errors'][0]
# no new versions of content view, any existing remained the same
assert content_view.read().version == existing_versions

@pytest.mark.tier2
def test_negative_add_components_to_composite(
self, content_view, module_org, module_target_sat
Expand Down

0 comments on commit dac8623

Please sign in to comment.