From f88f226c8eebee50d210b9c231ae67ca6c6202b9 Mon Sep 17 00:00:00 2001 From: vijaysawant Date: Tue, 4 Jun 2024 20:03:15 +0530 Subject: [PATCH] add manifest expired time in robottelo constants and tested --- robottelo/constants/__init__.py | 1 + tests/foreman/ui/test_subscription.py | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index ee8dc363870..4207bd0c9ea 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -2077,6 +2077,7 @@ ) EXPIRED_MANIFEST = 'expired-manifest.zip' +EXPIRED_MANIFEST_DATE = 'Fri Dec 03 2021' # Data File Paths diff --git a/tests/foreman/ui/test_subscription.py b/tests/foreman/ui/test_subscription.py index 0ea8523cfe4..48ba4162db3 100644 --- a/tests/foreman/ui/test_subscription.py +++ b/tests/foreman/ui/test_subscription.py @@ -12,6 +12,7 @@ """ +from datetime import datetime, timedelta from tempfile import mkstemp import time @@ -22,6 +23,7 @@ from robottelo.constants import ( DEFAULT_SUBSCRIPTION_NAME, EXPIRED_MANIFEST, + EXPIRED_MANIFEST_DATE, PRDS, REPOS, REPOSET, @@ -561,7 +563,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. @@ -572,13 +574,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 @@ -598,8 +600,10 @@ 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'] + 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'] @@ -607,8 +611,7 @@ def test_positive_check_manifest_validity_notification( # 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() ) @@ -618,17 +621,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']