Skip to content

Commit

Permalink
feat: set "trace" as log level for rhc
Browse files Browse the repository at this point in the history
Use the "toml" Python package to parse and save /etc/rhc/config.toml,
so it is more reliable than custom editing/parsing.

Set "log-level" as "trace", so it is consistent with what already done
with subscription-manager.

Signed-off-by: Pino Toscano <[email protected]>
  • Loading branch information
ptoscano committed Aug 15, 2024
1 parent 2750977 commit 00cd9c4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Plugin for `pytest` to test RHSM client tools: `subscription-manager`,
## Requirements

- requests
- toml

## Installation

Expand Down
12 changes: 12 additions & 0 deletions pytest_client_tools/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import functools
import locale
import logging
import pathlib
import shutil
import subprocess

import pytest
import toml

from .candlepin import Candlepin, ping_candlepin
from .inventory import Inventory
Expand Down Expand Up @@ -225,6 +227,16 @@ def save_rhc_files(request):
@pytest.fixture
def rhc(save_rhc_files, test_config):
rhc = Rhc()
config_file = pathlib.Path("/etc/rhc/config.toml")
try:
config = toml.loads(config_file.read_text())
except toml.TomlDecodeError as e:
LOGGER.warning(
"cannot load %s as TOML (skipping customizations): %s", config_file, e
)
else:
config["log-level"] = "trace"
config_file.write_text(toml.dumps(config))
try:
yield rhc
finally:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def read(fname):
"dynaconf",
"pytest>=4",
"requests",
"toml",
],
classifiers=[
"Development Status :: 4 - Beta",
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ dynaconf
flake8
pytest>=4
requests
toml

0 comments on commit 00cd9c4

Please sign in to comment.