forked from SatelliteQE/robottelo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_documentation_links.py
More file actions
127 lines (103 loc) · 4.01 KB
/
Copy pathtest_documentation_links.py
File metadata and controls
127 lines (103 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
"""Test module for verifying Documentation links
:Requirement: Branding
:CaseAutomation: Automated
:CaseComponent: Branding
:Team: Endeavour
:CaseImportance: High
"""
import pytest
import requests
from robottelo.config import settings
from robottelo.logging import logger
pages = [
'about',
'settings',
'bookmark',
'role',
'ldapauthentication',
'cloudinventory',
'ansiblevariables',
'ansibleroles',
'discoveryrule',
'global_parameter',
'oscapreport',
'oscappolicy',
'oscapcontent',
'jobtemplate',
'provisioningtemplate',
'partitiontable',
'operatingsystem',
'host',
'discoveredhosts',
'reporttemplate',
'configreport',
'jobinvocation',
'audit',
'factvalue',
'dashboard',
]
@pytest.fixture(scope='module')
def session(module_target_sat):
"""Helper function to create a session for testing documentation links."""
with module_target_sat.ui_session() as session:
yield session
@pytest.mark.parametrize('page', pages)
@pytest.mark.e2e
def test_positive_documentation_links(module_target_sat, session, page):
"""Verify that Satellite documentation links are working.
Note: At the moment, the test doesn't support verifying links hidden behind a button.
Currently, the only such link is on RH Cloud > Inventory Upload page.
:id: 5e6cba22-896a-4d86-95b4-87d0cc2f1cb6
:Steps:
1. Gather documentation links present on various Satellite pages.
2. Verify the links are working (returns 200).
:expectedresults: All the Documentation links present on Satellite are working
"""
sat_version = ".".join(module_target_sat.version.split('.')[0:2])
all_links = []
broken_links = []
page_object = getattr(session, page)
if page == "host":
view = page_object.navigate_to(page_object, 'Register')
elif page == "oscappolicy":
view = page_object.navigate_to(page_object, 'New')
else:
view = page_object.navigate_to(page_object, 'All')
# Get the doc links present on the page.
all_links = view.documentation_links()
assert all_links, f"Couldn't find any documentation links on {page} page."
logger.info(f"Following are the documentation links collected from Satellite: \n {all_links}")
for link in all_links:
# Test stage docs url for Non-GA'ed Satellite
if float(sat_version) in settings.robottelo.sat_non_ga_versions:
# The internal satellite doc url redirects to prod doc that is not available for Non-GA versions.
# Get the end url first and then update it in later part of test.
if module_target_sat.hostname in link:
link = requests.get(link, verify=False).url
link = link.replace('https://docs.redhat.com', settings.robottelo.stage_docs_url)
if requests.get(link, verify=False).status_code != 200:
broken_links.append(link)
logger.info(f"Following link on {page} page seems broken: \n {link}")
assert not broken_links, (
f"There are broken documentation links on page \"{page}\": \n {broken_links}"
)
@pytest.mark.e2e
def test_positive_upgrade_links(target_sat):
"""Verify that Satellite Upgrade links are present and working.
:id: 1535c21d-2b75-450d-af63-55d268f8479e
:Steps:
1. Gather documentation links present on Administer -> Satellite Upgrade page
2. Verify the links are working (returns 200).
:expectedresults: All the Upgrade links present on Satellite are working
:Verifies: SAT-20700, SAT-35235
"""
with target_sat.ui_session() as session:
links = session.upgrade.documentation_links()
assert (
'https://access.redhat.com/login?redirectTo=https%3A%2F%2Faccess.redhat.com%2Flabs%2Fsatelliteupgradehelper%2F'
in links
)
assert (
'https://access.redhat.com/products/red-hat-satellite#get-support' in links
or 'https://access.redhat.com/products/red-hat-satellite/#get-support' in links
)