Skip to content

Commit 5c7a81a

Browse files
kmeinerzkmeinerz1
andauthored
Fix test config endless load (#798)
* fixed bug * added changelog entry --------- Co-authored-by: kmeinerz1 <kaithomas.meinerz@bwi.de>
1 parent 0dd02c2 commit 5c7a81a

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
### Bugfix
1111

1212
- Fixed logging error in _revoke_callback() by adding error handling
13+
- Fixed endless loading in logprep test config
1314

1415
## 16.1.0
1516
### Deprecations

logprep/run_logprep.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from logprep.util.configuration import Configuration, InvalidConfigurationError
1818
from logprep.util.defaults import DEFAULT_LOG_CONFIG, EXITCODES
1919
from logprep.util.helper import get_versions_string, print_fcolor
20+
from logprep.util.logging import LogprepMPQueueListener, logqueue
2021
from logprep.util.pseudo.commands import depseudonymize, generate_keys, pseudonymize
2122
from logprep.util.rule_dry_runner import DryRunner
2223

@@ -37,7 +38,14 @@ def _get_configuration(config_paths: tuple[str]) -> Configuration:
3738
config = Configuration.from_sources(config_paths)
3839
config.logger.setup_logging()
3940
logger = logging.getLogger("root") # pylint: disable=redefined-outer-name
41+
42+
console_logger = logging.getLogger("console")
43+
console_handler = console_logger.handlers[0]
44+
listener = LogprepMPQueueListener(logqueue, console_handler)
45+
listener.start()
46+
4047
logger.info(f"Log level set to '{logging.getLevelName(logger.level)}'")
48+
listener.stop()
4149
return config
4250
except InvalidConfigurationError as error:
4351
print(f"InvalidConfigurationError: {error}", file=sys.stderr)
@@ -62,7 +70,7 @@ def cli() -> None:
6270
"--version",
6371
is_flag=True,
6472
default=False,
65-
help="Print version and exit (includes also congfig version)",
73+
help="Print version and exit (includes also config version)",
6674
)
6775
def run(configs: tuple[str], version=None) -> None:
6876
"""

tests/unit/test_run_logprep.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ def test_test_config_verifies_configuration_successfully(self, mock_verify):
122122
mock_verify.assert_called()
123123
assert "The verification of the configuration was successful" in result.stdout
124124

125+
@mock.patch("logprep.run_logprep.LogprepMPQueueListener")
126+
def test_listener_start_and_stop_called(self, mock_listener_cls):
127+
mock_listener = mock.Mock()
128+
mock_listener_cls.return_value = mock_listener
129+
130+
args = ["test", "config", "tests/testdata/config/config.yml"]
131+
result = self.cli_runner.invoke(cli, args)
132+
133+
assert mock_listener.start.called, "Listener start() was not called"
134+
assert mock_listener.stop.called, "Listener stop() was not called"
135+
125136
@mock.patch("logprep.util.configuration.Configuration._verify")
126137
def test_test_config_verifies_configuration_unsuccessfully(self, mock_verify):
127138
mock_verify.side_effect = InvalidConfigurationError("test error")

0 commit comments

Comments
 (0)