Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: User to be warned about incorrect delimiter #263

Merged
merged 1 commit into from
May 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import argparse
import io
import logging
import os
import tempfile
from contextlib import redirect_stdout
Expand Down Expand Up @@ -104,3 +105,35 @@ def test_incorrect_output_type_cfg_file(mock_parse, mock_run, mock_service):

finally:
os.remove(config_path)


@patch('ipahealthcheck.core.core.run_service_plugins')
@patch('ipahealthcheck.core.core.run_plugins')
@patch('ipahealthcheck.core.core.parse_options')
def test_incorrect_delimiter_cfg_file(mock_parse, mock_run, mock_service,
caplog):
"""
Test the error message is user-friendly if the incorrect delimiter is
used in cfg file

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2079739
"""
mock_service.return_value = (Results(), [])
mock_run.return_value = Results()
mock_parse.return_value = options
fd, config_path = tempfile.mkstemp()
os.close(fd)
with open(config_path, "w") as fd:
fd.write('[default]\n')
fd.write('output_type;human\n')

try:
run = RunChecks([], config_path)

with caplog.at_level(logging.ERROR):
run.run_healthcheck()

assert "contains parsing errors" in caplog.text

finally:
os.remove(config_path)