Skip to content

Allow host_conf usage w/o request fixture#21484

Open
lpramuk wants to merge 1 commit into
SatelliteQE:masterfrom
lpramuk:host_conf_unparametrized
Open

Allow host_conf usage w/o request fixture#21484
lpramuk wants to merge 1 commit into
SatelliteQE:masterfrom
lpramuk:host_conf_unparametrized

Conversation

@lpramuk
Copy link
Copy Markdown
Contributor

@lpramuk lpramuk commented May 6, 2026

Problem Statement

contenthost_factory always requires the fixture to be parametrized:

@pytest.fixture(params=[{'rhel_version': 8, 'no_containers': True}])
def external_server(request):
    with contenthost_factory(request=request) as host:

Removing unnecessary fixture parametrization w/o removing contenthost_factory is not possible:

@pytest.fixture
def external_server():
    with contenthost_factory(request={'param': {'rhel_version': 9, 'no_containers': True}}) as host:

^ impossible code

Solution

In host_conf() add handling of dictionary object mimicking request in order to allow unparametrized fixtures to still use contenthost_factory

Related Issues

Summary by Sourcery

Allow content host configuration fixture to be used without a pytest request object and update external puppet server provisioning to RHEL 9 with revised test conditions.

Bug Fixes:

  • Enable host_conf fixture to accept configuration via plain parameter dictionaries in addition to pytest request objects.

Enhancements:

  • Simplify no-containers option handling in host_conf to use clearer boolean logic.
  • Update external_puppet_server fixture to provision RHEL 9 content hosts and install the corresponding Puppet repository.
  • Adjust provisioning test markers and skip conditions to cover RHEL 7–10 and reflect current openvox-agent availability issues.

Summary by Sourcery

Allow content host configuration to accept plain parameter dictionaries in addition to pytest request objects when used by fixtures.

Bug Fixes:

  • Enable host_conf to read parameters from a dictionary with a 'param' key, allowing use of contenthost_factory without a parametrized pytest request fixture.

Enhancements:

  • Simplify no-containers handling in host_conf by using clearer boolean logic when deciding whether to configure container deployment.

@lpramuk lpramuk self-assigned this May 6, 2026
@lpramuk lpramuk added CherryPick PR needs CherryPick to previous branches AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing 6.16.z 6.17.z 6.18.z Introduced in or relating directly to Satellite 6.18 6.19.z labels May 6, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 6, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Allow the host_conf fixture to accept a plain dict mimicking pytest’s request object so contenthost_factory can be used from unparametrized fixtures, and simplify the no-containers flag logic.

File-Level Changes

Change Details Files
Extend host_conf to work with dict-style request objects while simplifying no-containers handling.
  • Treat a request-like dict with a 'param' key as a source of parameters when no pytest request.param is present.
  • Preserve existing behavior when a real pytest request object with a .param attribute is provided.
  • Refactor the conditional that controls container deployment to a simpler boolean expression that checks fixture params, CLI --no-containers, and the no_containers marker in a clear order.
pytest_fixtures/core/contenthosts.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@lpramuk lpramuk force-pushed the host_conf_unparametrized branch from a766569 to 4b0cfd0 Compare May 6, 2026 10:34
@lpramuk lpramuk marked this pull request as ready for review May 6, 2026 10:36
@lpramuk lpramuk requested a review from a team as a code owner May 6, 2026 10:36
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The new elif 'param' in request: branch will raise a TypeError when request is a pytest FixtureRequest without param; consider explicitly checking isinstance(request, dict) (or similar) before doing a membership test on it.
  • When supporting both dict-like and FixtureRequest inputs in host_conf, it may be safer to avoid accessing request.config / request.node unconditionally and instead gate those attribute accesses behind an hasattr/isinstance check to prevent misuse with plain dicts.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `elif 'param' in request:` branch will raise a `TypeError` when `request` is a `pytest` `FixtureRequest` without `param`; consider explicitly checking `isinstance(request, dict)` (or similar) before doing a membership test on it.
- When supporting both dict-like and `FixtureRequest` inputs in `host_conf`, it may be safer to avoid accessing `request.config` / `request.node` unconditionally and instead gate those attribute accesses behind an `hasattr`/`isinstance` check to prevent misuse with plain dicts.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@lpramuk lpramuk requested a review from JacobCallahan May 6, 2026 23:10
@lpramuk
Copy link
Copy Markdown
Contributor Author

lpramuk commented May 7, 2026

test_host_registration_end_to_end uses request.param['no_containers']
test_positive_run_default_job_template uses @pytest.mark.no_containers

So both way are covered by PRT

@Satellite-QE
Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 15314
Build Status: SUCCESS
PRT Comment: pytest -v tests/foreman/api/test_registration.py::test_host_registration_end_to_end tests/foreman/cli/test_remoteexecution.py::TestRemoteExecution::test_positive_run_default_job_template --external-logging
Test Result : ================= 5 passed, 45 warnings in 2891.31s (0:48:11) ==================

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label May 7, 2026
@lpramuk lpramuk removed the 6.16.z label May 13, 2026
@lpramuk lpramuk force-pushed the host_conf_unparametrized branch from 4b0cfd0 to 60a6975 Compare May 26, 2026 10:25
@Satellite-QE Satellite-QE removed the PRT-Passed Indicates that latest PRT run is passed for the PR label May 26, 2026
@lpramuk
Copy link
Copy Markdown
Contributor Author

lpramuk commented May 26, 2026

trigger: test-robottelo
pytest: >-
  -v
  tests/foreman/api/test_registration.py::test_host_registration_end_to_end
  tests/foreman/cli/test_remoteexecution.py::TestRemoteExecution::test_positive_run_default_job_template

@lpramuk lpramuk force-pushed the host_conf_unparametrized branch from 60a6975 to 4c568c8 Compare May 26, 2026 16:04
@lpramuk
Copy link
Copy Markdown
Contributor Author

lpramuk commented May 26, 2026

trigger: test-robottelo
pytest: >-
  -v
  tests/foreman/api/test_registration.py::test_host_registration_end_to_end
  tests/foreman/cli/test_remoteexecution.py::TestRemoteExecution::test_positive_run_default_job_template

@lpramuk
Copy link
Copy Markdown
Contributor Author

lpramuk commented May 26, 2026

trigger: test-robottelo
pytest: >-
  -v
  tests/foreman/api/test_registration.py::test_host_registration_end_to_end
  tests/foreman/cli/test_remoteexecution.py::TestRemoteExecution::test_positive_run_default_job_template

@Satellite-QE
Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 15616
Build Status: SUCCESS
PRT Comment: pytest -v tests/foreman/api/test_registration.py::test_host_registration_end_to_end tests/foreman/cli/test_remoteexecution.py::TestRemoteExecution::test_positive_run_default_job_template --external-logging
Test Result : ================= 5 passed, 45 warnings in 3147.71s (0:52:27) ==================

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label May 26, 2026
@Satellite-QE
Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 15624
Build Status: SUCCESS
PRT Comment: pytest -v tests/foreman/api/test_registration.py::test_host_registration_end_to_end tests/foreman/cli/test_remoteexecution.py::TestRemoteExecution::test_positive_run_default_job_template --external-logging
Test Result : ================= 5 passed, 46 warnings in 2982.90s (0:49:42) ==================

@lpramuk
Copy link
Copy Markdown
Contributor Author

lpramuk commented May 27, 2026

trigger: test-robottelo
pytest: >-
  -v
  tests/foreman/api/test_registration.py::test_host_registration_end_to_end
  tests/foreman/cli/test_remoteexecution.py::TestRemoteExecution::test_positive_run_default_job_template

1 similar comment
@lpramuk
Copy link
Copy Markdown
Contributor Author

lpramuk commented May 27, 2026

trigger: test-robottelo
pytest: >-
  -v
  tests/foreman/api/test_registration.py::test_host_registration_end_to_end
  tests/foreman/cli/test_remoteexecution.py::TestRemoteExecution::test_positive_run_default_job_template

@lpramuk
Copy link
Copy Markdown
Contributor Author

lpramuk commented May 27, 2026

trigger: test-robottelo
pytest: >-
  -v
  tests/foreman/api/test_registration.py::test_host_registration_end_to_end
  tests/foreman/cli/test_remoteexecution.py::TestRemoteExecution::test_positive_run_default_job_template

@lpramuk
Copy link
Copy Markdown
Contributor Author

lpramuk commented May 27, 2026

trigger: test-robottelo
pytest: >-
  -v
  tests/foreman/api/test_registration.py::test_host_registration_end_to_end
  tests/foreman/cli/test_remoteexecution.py::TestRemoteExecution::test_positive_run_default_job_template

@Satellite-QE
Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 15629
Build Status: SUCCESS
PRT Comment: pytest -v tests/foreman/api/test_registration.py::test_host_registration_end_to_end tests/foreman/cli/test_remoteexecution.py::TestRemoteExecution::test_positive_run_default_job_template --external-logging
Test Result : ================= 5 passed, 46 warnings in 2968.83s (0:49:28) ==================

@Satellite-QE
Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 15630
Build Status: SUCCESS
PRT Comment: pytest -v tests/foreman/api/test_registration.py::test_host_registration_end_to_end tests/foreman/cli/test_remoteexecution.py::TestRemoteExecution::test_positive_run_default_job_template --external-logging
Test Result : ================= 5 passed, 45 warnings in 3011.64s (0:50:11) ==================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.17.z 6.18.z Introduced in or relating directly to Satellite 6.18 6.19.z AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing CherryPick PR needs CherryPick to previous branches PRT-Passed Indicates that latest PRT run is passed for the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants