Skip to content

Commit

Permalink
add manifest expired time in robottelo constants and tested
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaysawant committed Jun 5, 2024
1 parent f4bce9a commit 02d68ac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,7 @@
)

EXPIRED_MANIFEST = 'expired-manifest.zip'
EXPIRED_MANIFEST_DATE = 'Fri Dec 03 2021'


# Data File Paths
Expand Down
29 changes: 18 additions & 11 deletions tests/foreman/ui/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""

from datetime import datetime, timedelta
from tempfile import mkstemp
import time

Expand All @@ -22,13 +23,15 @@
from robottelo.constants import (
DEFAULT_SUBSCRIPTION_NAME,
EXPIRED_MANIFEST,
EXPIRED_MANIFEST_DATE,
PRDS,
REPOS,
REPOSET,
VDC_SUBSCRIPTION_NAME,
VIRT_WHO_HYPERVISOR_TYPES,
DataFile,
)
from robottelo.utils.issue_handlers import is_open
from robottelo.utils.manifest import clone

pytestmark = [pytest.mark.run_in_one_thread, pytest.mark.skip_if_not_set('fake_manifest')]
Expand Down Expand Up @@ -561,7 +564,7 @@ def test_positive_prepare_for_sca_only_subscription(target_sat, function_entitle

@pytest.mark.parametrize('setting_update', ['expire_soon_days'], indirect=True)
def test_positive_check_manifest_validity_notification(
target_sat, setting_update, function_org, function_sca_manifest, default_org
target_sat, setting_update, function_org, function_sca_manifest
):
"""Check notification when manifest is going to expire.
Expand All @@ -572,13 +575,13 @@ def test_positive_check_manifest_validity_notification(
:steps:
1. Upload expired manifest in newly created org
2. go to Content > Subscriptions page, click on 'Manage Manifest' button.
2. Go to Content > Subscriptions page, click on 'Manage Manifest' button.
3. Search for message string 'Manifest expired', or 'Your manifest expired'
4. delete expired manifest from this org (cleanup part)
4. Delete expired manifest from this org (cleanup part)
5. Upload non-expired manifest
6. go to Content > Subscription page, click on 'Manage Manifest' button.
6. Go to Content > Subscription page, click on 'Manage Manifest' button.
7. Search for message string 'Manifest expiring soon', or 'Your manifest will expire'
8. delete expired manifest from this org (cleanup part)
8. Delete expired manifest from this org (cleanup part)
:expectedresults:
1. 'Manifest expired', 'Manifest expiring soon' messages appear on Manage Manifest modal box
Expand All @@ -598,17 +601,19 @@ def test_positive_check_manifest_validity_notification(
# read expire manifest message
expired_manifest = session.subscription.read_subscription_manifest_header_message_and_date()
assert 'Manifest expired' in expired_manifest['header'], 'Manifest expire alert not found'
assert 'Your manifest expired' in expired_manifest['message']
assert 'import a new manifest' in expired_manifest['message']
if not is_open('SAT-25052'):
assert (
f'Your manifest expired on {EXPIRED_MANIFEST_DATE}. To continue using '
f'Red Hat content, import a new manifest.' in expired_manifest['message']
)
# Cleanup - delete expired manifest
session.subscription.delete_manifest(
ignore_error_messages=['Danger alert: Katello::Errors::UpstreamConsumerNotFound']
)

# Message - Manifest expiring soon
# Upload non-expire manifest
session.organization.select(default_org.name)
target_sat.upload_manifest(default_org.id, function_sca_manifest.content)
target_sat.upload_manifest(function_org.id, function_sca_manifest.content)
original_expire_date = (
session.subscription.read_subscription_manifest_expiration_date_only()
)
Expand All @@ -618,17 +623,19 @@ def test_positive_check_manifest_validity_notification(
setting_update.value = 366
setting_update = setting_update.update({'value'})
session.browser.refresh()
# Predict expire date using below formula
date = datetime.now() + timedelta(days=365)
formatted_date = date.strftime('%a %b %d %Y')
# read expire manifest message
expiring_soon = session.subscription.read_subscription_manifest_header_message_and_date()
assert (
'Manifest expiring soon' in expiring_soon['header']
), 'Manifest expire alert not found'
assert 'Your manifest will expire' in expiring_soon['message']
assert 'import a new manifest' in expiring_soon['message']

session.subscription.refresh_manifest()
updated_expire_date = session.subscription.read_subscription_manifest_expiration_date_only()
assert original_expire_date != updated_expire_date
assert formatted_date in updated_expire_date
# Cleanup - delete non-expired manifest
session.subscription.delete_manifest(
ignore_error_messages=['Danger alert: Katello::Errors::UpstreamConsumerNotFound']
Expand Down

0 comments on commit 02d68ac

Please sign in to comment.