forked from SatelliteQE/robottelo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaxonomy.py
More file actions
232 lines (167 loc) · 8.64 KB
/
Copy pathtaxonomy.py
File metadata and controls
232 lines (167 loc) · 8.64 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# Content Component fixtures
from manifester import Manifester
import pytest
from robottelo.config import settings
from robottelo.constants import DEFAULT_LOC, DEFAULT_ORG
@pytest.fixture(scope='session')
def default_org(session_target_sat):
return session_target_sat.api.Organization().search(query={'search': f'name="{DEFAULT_ORG}"'})[
0
]
@pytest.fixture(scope='session')
def default_location(session_target_sat):
return session_target_sat.api.Location().search(query={'search': f'name="{DEFAULT_LOC}"'})[0]
@pytest.fixture
def current_sat_org(target_sat):
"""Return the current organization assigned to the Satellite host"""
sat_host = target_sat.api.Host().search(query={'search': f'name={target_sat.hostname}'})[0]
return sat_host.organization.read()
@pytest.fixture
def current_sat_location(target_sat):
"""Return the current location assigned to the Satellite host"""
sat_host = target_sat.api.Host().search(query={'search': f'name={target_sat.hostname}'})[0]
return sat_host.location.read()
@pytest.fixture
def function_org(target_sat):
return target_sat.api.Organization().create()
@pytest.fixture(scope='module')
def module_org(module_target_sat):
return module_target_sat.api.Organization().create()
@pytest.fixture(scope='class')
def class_org(class_target_sat):
org = class_target_sat.api.Organization().create()
yield org
org.delete()
@pytest.fixture(scope='module')
def module_location(module_target_sat, module_org):
return module_target_sat.api.Location(organization=[module_org]).create()
@pytest.fixture(scope='class')
def class_location(class_target_sat, class_org):
loc = class_target_sat.api.Location(organization=[class_org]).create()
yield loc
loc.delete()
@pytest.fixture
def function_location(target_sat):
return target_sat.api.Location().create()
@pytest.fixture
def function_location_with_org(target_sat, function_org):
return target_sat.api.Location(organization=[function_org]).create()
@pytest.fixture(scope='module')
def module_sca_manifest_org(module_org, module_sca_manifest, module_target_sat):
"""Creates an organization and uploads an SCA mode manifest generated with manifester"""
module_target_sat.upload_manifest(module_org.id, module_sca_manifest.content)
return module_org
@pytest.fixture(scope='class')
def class_sca_manifest_org(class_org, class_sca_manifest, class_target_sat):
"""Creates an organization and uploads an SCA mode manifest generated with manifester"""
class_target_sat.upload_manifest(class_org.id, class_sca_manifest.content)
return class_org
@pytest.fixture
def sca_manifest_org_for_upgrade(function_org, sca_manifest_for_upgrade, target_sat):
"""A Pytest fixture that creates an organization and uploads an sca mode manifest
generated with Manifester. This will be used for upgrade scenarios"""
sca_manifest, _ = sca_manifest_for_upgrade
target_sat.upload_manifest(function_org.id, sca_manifest.content)
return function_org
@pytest.fixture
def function_sca_manifest_org(function_org, function_sca_manifest, target_sat):
"""Creates an organization and uploads an SCA mode manifest generated with manifester"""
target_sat.upload_manifest(function_org.id, function_sca_manifest.content)
return function_org
@pytest.fixture
def function_els_sca_manifest_org(function_org, function_sca_els_manifest, target_sat):
"""Creates an organization and uploads an SCA mode manifest generated with manifester"""
target_sat.upload_manifest(function_org.id, function_sca_els_manifest.content)
return function_org
@pytest.fixture(scope='module')
def module_els_sca_manifest_org(module_org, module_sca_els_manifest, module_target_sat):
"""Creates an organization and uploads an SCA mode manifest generated with manifester"""
module_target_sat.upload_manifest(module_org.id, module_sca_els_manifest.content)
return module_org
@pytest.fixture(scope='class')
def class_els_sca_manifest_org(class_org, class_sca_els_manifest, class_target_sat):
"""Creates an organization and uploads an SCA mode manifest generated with manifester"""
class_target_sat.upload_manifest(class_org.id, class_sca_els_manifest.content)
return class_org
# Note: Manifester should not be used with the Satellite QE RHSM account until
# subscription needs are scoped and sufficient subscriptions added to the
# Satellite QE RHSM account. Manifester can be safely used locally with personal
# or stage RHSM accounts.
@pytest.fixture(scope='session')
def session_sca_manifest():
"""Yields a manifest in entitlement mode with subscriptions determined by the
`manifest_category.entitlement` setting in conf/manifest.yaml."""
with Manifester(manifest_category=settings.manifest.golden_ticket) as manifest:
yield manifest
@pytest.fixture(scope='module')
def module_extra_rhel_sca_manifest():
"""Yields a manifest in sca mode with subscriptions determined by the
'manifest_category.extra_rhel_entitlement` setting in conf/manifest.yaml."""
with Manifester(manifest_category=settings.manifest.extra_rhel_entitlement) as manifest:
yield manifest
@pytest.fixture(scope='module')
def module_sca_manifest():
"""Yields a manifest in Simple Content Access mode with subscriptions determined by the
`manifest_category.golden_ticket` setting in conf/manifest.yaml."""
with Manifester(manifest_category=settings.manifest.golden_ticket) as manifest:
yield manifest
@pytest.fixture(scope='class')
def class_sca_manifest():
"""Yields a manifest in Simple Content Access mode with subscriptions determined by the
`manifest_category.golden_ticket` setting in conf/manifest.yaml."""
with Manifester(manifest_category=settings.manifest.golden_ticket) as manifest:
yield manifest
@pytest.fixture
def function_sca_manifest():
"""Yields a manifest in Simple Content Access mode with subscriptions determined by the
`manifest_category.golden_ticket` setting in conf/manifest.yaml."""
with Manifester(manifest_category=settings.manifest.golden_ticket) as manifest:
yield manifest
@pytest.fixture
def second_function_sca_manifest():
"""Yields a manifest in Simple Content Access mode with subscriptions determined by the
`manifest_category.golden_ticket` setting in conf/manifest.yaml.
A different one than is used in `function_sca_manifest_org`."""
with Manifester(manifest_category=settings.manifest.golden_ticket) as manifest:
yield manifest
@pytest.fixture(scope='module')
def module_sca_els_manifest():
"""Yields a manifest in Simple Content Access mode with subscriptions determined by the
`manifest_category.els_rhel_manifest` setting in conf/manifest.yaml."""
with Manifester(manifest_category=settings.manifest.els_rhel_manifest) as manifest:
yield manifest
@pytest.fixture(scope='class')
def class_sca_els_manifest():
"""Yields a manifest in Simple Content Access mode with subscriptions determined by the
`manifest_category.els_rhel_manifest` setting in conf/manifest.yaml."""
with Manifester(manifest_category=settings.manifest.els_rhel_manifest) as manifest:
yield manifest
@pytest.fixture
def function_sca_els_manifest():
"""Yields a manifest in Simple Content Access mode with subscriptions determined by the
`manifest_category.els_rhel_manifest` setting in conf/manifest.yaml."""
with Manifester(manifest_category=settings.manifest.els_rhel_manifest) as manifest:
yield manifest
@pytest.fixture(scope='module')
def smart_proxy_location(module_org, module_target_sat, default_smart_proxy):
location = module_target_sat.api.Location(organization=[module_org]).create()
default_smart_proxy.location.append(module_target_sat.api.Location(id=location.id))
default_smart_proxy.update(['location'])
return location
@pytest.fixture
def upgrade_entitlement_manifest():
"""Returns a manifest in entitlement mode with subscriptions determined by the
`manifest_category.entitlement` setting in conf/manifest.yaml. used only for
upgrade scenarios"""
manifester = Manifester(manifest_category=settings.manifest.entitlement)
return manifester.get_manifest(), manifester
@pytest.fixture
def sca_manifest_for_upgrade():
"""Returns a manifest in sca mode. Used only for upgrade scenarios"""
manifester = Manifester(manifest_category=settings.manifest.golden_ticket)
return manifester.get_manifest(), manifester
@pytest.fixture
def func_future_dated_subscription_manifest():
"""Returns future dated manifest. Used only for future date subscription scenarios."""
with Manifester(manifest_category=settings.manifest.future_date_subscription) as manifest:
yield manifest