Skip to content

Commit

Permalink
feat: make "subman" work together with "subman_global"
Browse files Browse the repository at this point in the history
Change the implementation of the "subman" fixture to not do any action
in case the "subman_global" fixture is already in use: this means that
the configuration/subscription is driven by "subman_global", so "subman"
must do not do anything.

Signed-off-by: Pino Toscano <[email protected]>
  • Loading branch information
ptoscano committed Jan 15, 2024
1 parent 36fae6c commit f26af8f
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions pytest_client_tools/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,28 +139,34 @@ def _subman_common(request):
None,
)
subman = SubscriptionManager()
# TODO enable debug also for all the categories
subman.config(
logging_default_log_level="DEBUG",
has_subman_global = (
request.fixturename != "subman_global"
and "subman_global" in request.fixturenames
)
if candlepin_fixture:
candlepin = request.getfixturevalue(candlepin_fixture)
if not has_subman_global:
# TODO enable debug also for all the categories
subman.config(
server_hostname=candlepin.host,
server_port=candlepin.port,
server_prefix=candlepin.prefix,
server_insecure="1" if candlepin.insecure else "0",
)
else:
subman.config(
server_hostname="invalid-hostname-set-to-avoid-mistakes",
logging_default_log_level="DEBUG",
)
if candlepin_fixture:
candlepin = request.getfixturevalue(candlepin_fixture)
subman.config(
server_hostname=candlepin.host,
server_port=candlepin.port,
server_prefix=candlepin.prefix,
server_insecure="1" if candlepin.insecure else "0",
)
else:
subman.config(
server_hostname="invalid-hostname-set-to-avoid-mistakes",
)
try:
yield subman
finally:
with contextlib.suppress(subprocess.SubprocessError):
subman.unregister()
stop_rhsmcertd()
if not has_subman_global:
with contextlib.suppress(subprocess.SubprocessError):
subman.unregister()
stop_rhsmcertd()


@pytest.fixture
Expand Down

0 comments on commit f26af8f

Please sign in to comment.