3737- Location: ` tests/foreman/api/ `
3838- Example: ` tests/foreman/api/test_activationkey.py `
3939
40- ** Upgrade Tests** : Uses` SharedResource ` for single-test upgrade scenarios:
41- - Location: ' tests/new_upgrades'
42- - Example: ' tests' new_upgrades/test_activation_key.py'
40+ ** Upgrade Tests** : Uses ` SharedResource ` for single-test upgrade scenarios:
41+ - Location: ` tests/new_upgrades `
42+ - Example: ` tests/ new_upgrades/test_activation_key.py `
4343
4444---
4545
@@ -78,7 +78,7 @@ The bottom layer containing helper classes, utilities, and base implementations.
7878- ** Location** : ` robottelo/ `
7979- ** Components** :
8080 - ** API helpers** : ` robottelo/api/ ` (Nailgun entities)
81- - ** Host classes** : ` robottelo.hosts.py ` (Base functionality for ContentHost, Capsule, Satellite interaction s )
81+ - ** Host classes** : ` robottelo.hosts.py ` (Base functionality for ContentHost, Capsule, Satellite interactions )
8282 - ** CLI helpers** : ` robottelo/cli/ ` (Hammer command wrappers)
8383 - ** Host helpers** : ` robottelo/host_helpers/ ` (Satellite/ContentHost mixins)
8484 - ** Utilities** : ` robottelo/utils/ ` (decorators, data factories, etc.)
@@ -110,9 +110,9 @@ Pytest fixtures provide test dependencies and setup/teardown logic.
110110
111111** Fixture Scopes** :
112112- ` function ` : Per test function (default)
113+ - ` class ` : Per test class
113114- ` module ` : Per test module
114115- ` session ` : Per test session
115- - ` class ` : Per test class
116116
117117Example:
118118
@@ -175,7 +175,7 @@ ak = target_sat.api.ActivationKey(organization=org).create()
175175# Using UI session
176176with target_sat.ui_session() as session:
177177 session.organization.select(' ORG_NAME' )
178- session.location.select(' LOC_NAME' )
178+ session.location.select(' LOC_NAME' )
179179 session.activationkey.create({' name' : ' my-ak' })
180180
181181# Using ContentHost methods
@@ -214,7 +214,6 @@ email = gen_email() # Random email
214214
215215``` python
216216# Standard library
217- from robottelo.logging import logger
218217from datetime import datetime
219218
220219# Third-party
@@ -225,6 +224,7 @@ from nailgun.entities import ActivationKey
225224# Robottelo
226225from robottelo.config import settings
227226from robottelo.constants import DEFAULT_CV
227+ from robottelo.logging import logger
228228from robottelo.utils.datafactory import gen_string
229229```
230230
@@ -245,7 +245,7 @@ Test names follow a specific pattern to indicate expected behavior:
245245
246246- ` test_positive_* ` : Test should succeed (happy path)
247247- ` test_negative_* ` : Test should fail with expected error (error handling)
248- - ` test_upgrade_ *` : Upgrade scenario test
248+ - ` test_post_ *` : Post-upgrade scenario test
249249
250250Examples:
251251- ` test_positive_create_activation_key_with_cv() `
@@ -260,7 +260,7 @@ Use **reStructuredText** format with required fields, Reference `testimony.yaml`
260260def test_positive_create_activation_key (module_org , module_target_sat ):
261261 """ Create activation key with valid name
262262
263- :id: 1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d <uuid generated with 'uuidgen | tr "[:upper:]" "[:lower:]"' >
263+ :id: 1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d <generated uuid >
264264
265265 :steps:
266266 1. Create organization
@@ -278,11 +278,11 @@ def test_positive_create_activation_key(module_org, module_target_sat):
278278```
279279
280280** Required Fields** :
281- - ` :id: ` - Unique test UUID
281+ - ` :id: ` - Unique test UUID. Use ` python -c 'import uuid; print(uuid.uuid4())' ` to generate it
282282- ` :steps: ` - Test execution steps
283283- ` :expectedresults: ` - Expected outcome
284284
285- ** Optional fields**
285+ ** Optional fields** :
286286- ` :Verifies: ` - When the test verifies a Bug (Use as :Verifies: SAT-12345) (Formerly there was :BZ: tag, don't use that anymore)
287287---
288288
@@ -309,7 +309,7 @@ def test_positive_create_ak_via_ui(module_org, module_target_sat):
309309 assert ak_values[' details' ][' name' ] == ak_name
310310```
311311
312- ### Pattern 3 : CLI Test
312+ ### Pattern 2 : CLI Test
313313
314314``` python
315315def test_positive_create_ak_via_cli (module_org , module_target_sat ):
@@ -333,7 +333,7 @@ def test_positive_create_ak_via_cli(module_org, module_target_sat):
333333 assert ak_info[' name' ] == ak_name
334334```
335335
336- ### Pattern 4 : Parametrized Test
336+ ### Pattern 3 : Parametrized Test
337337
338338``` python
339339@pytest.mark.parametrize (' name' , [
@@ -362,7 +362,7 @@ def test_positive_create_with_different_names(name, module_org, module_target_sa
362362 indirect = True ,
363363 )
364364```
365- ### Pattern 5 : End-to-End Test
365+ ### Pattern 4 : End-to-End Test
366366
367367``` python
368368@pytest.mark.e2e
@@ -431,13 +431,18 @@ def module_satellite_iop(request, satellite_factory):
431431** ContentHost Fixtures** (` pytest_fixtures/core/contenthosts.py ` ):
432432
433433``` python
434- # RHEL ContentHost
434+ # RHEL ContentHost - parametrized for all supported RHEL versions defined in conf/supportability.yaml
435435@pytest.fixture
436436def rhel_contenthost (request ):
437437 """ Provides a RHEL content host"""
438438 ...
439439
440- # If there is no need for multiple RHEL versions to be tested, but RHEL host is still needed for the sake of the test.
440+ # Parametrized for N latest RHEL versions only (N-0 = latest, N-1 = latest two, etc.)
441+ @pytest.mark.rhel_ver_match (' N-1' )
442+ def test_latest_two_rhels (rhel_contenthost ):
443+ ...
444+
445+ # If there is no need for multiple RHEL versions to be tested, use only RHEL host of the default version specified in settings.
441446from robottelo.config import settings
442447@pytest.mark.rhel_ver_match ([settings.content_host.default_rhel_version])
443448def test_with_default_rhel (rhel_contenthost ):
@@ -511,18 +516,19 @@ def function_sca_manifest():
511516``` python
512517@pytest.mark.e2e # End-to-end tests
513518@pytest.mark.stubbed # Not yet implemented
514- @pytest.mark.destructive # Modifies Satellite config and needs satellite teardown
519+ @pytest.mark.destructive # Forces deployment of a new Satellite instance for a particular test case (more expensive)
515520@pytest.mark.skip_if_open () # Skip if BZ/issue open
516521```
517522
518523** Infrastructure Markers** :
524+ Content hosts are deployed in containers by default. If the host needs to run as a VM, use the ` no_containers ` marker.
519525``` python
520526@pytest.mark.no_containers # Cannot run in containers
521527```
522528
523529### RHEL Version Markers
524530
525- ** ` @pytest.mark.rhel_ver_match() ` ** : Match RHEL versions by regex
531+ ** ` @pytest.mark.rhel_ver_match() ` ** : Match RHEL versions based on versions defined in conf/supportability.yaml using regex, or by the N-x convention.
526532
527533``` python
528534# Match RHEL 9 and 10 (exclude 7 and 8)
@@ -533,6 +539,9 @@ def function_sca_manifest():
533539
534540# Match RHEL 9 including FIPS
535541@pytest.mark.rhel_ver_match (r ' ^ 9' ) # Matches 9, 9_fips
542+
543+ # Using N-x convention
544+ @pytest.mark.rhel_ver_match (' N-2' ) # Matches 3 latest RHEL versions
536545```
537546
538547** ` @pytest.mark.rhel_ver_list() ` ** : Specify exact RHEL versions
@@ -838,7 +847,7 @@ repo_url = settings.repos.yum_3.url
838847 - Action: ` create ` , ` update ` , ` delete ` , ` list `
839848
840849* ** Test Documentation:** Every test must have:
841- - Unique ` :id: ` UUID generated with 'uuidgen | tr " [ :upper: ] " " [ :lower: ] "'
850+ - Unique ` :id: ` UUID (use ` python -c 'import uuid; print(uuid.uuid4())' ` )
842851 - Clear ` :steps: `
843852 - Expected ` :expectedresults: `
844853
0 commit comments