Codebase list freeipa-healthcheck / 25fa4f3
Tests: User to be warned about incorrect delimiter Test if the error message is descriptive and informative when incorrect delimiter is supplied in the configuration file. Related: https://bugzilla.redhat.com/show_bug.cgi?id=2079739 Signed-off-by: Michal Polovka <mpolovka@redhat.com> Michal Polovka authored 1 year, 11 months ago Rob Crittenden committed 1 year, 11 months ago
1 changed file(s) with 33 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
33
44 import argparse
55 import io
6 import logging
67 import os
78 import tempfile
89 from contextlib import redirect_stdout
103104
104105 finally:
105106 os.remove(config_path)
107
108
109 @patch('ipahealthcheck.core.core.run_service_plugins')
110 @patch('ipahealthcheck.core.core.run_plugins')
111 @patch('ipahealthcheck.core.core.parse_options')
112 def test_incorrect_delimiter_cfg_file(mock_parse, mock_run, mock_service,
113 caplog):
114 """
115 Test the error message is user-friendly if the incorrect delimiter is
116 used in cfg file
117
118 Related: https://bugzilla.redhat.com/show_bug.cgi?id=2079739
119 """
120 mock_service.return_value = (Results(), [])
121 mock_run.return_value = Results()
122 mock_parse.return_value = options
123 fd, config_path = tempfile.mkstemp()
124 os.close(fd)
125 with open(config_path, "w") as fd:
126 fd.write('[default]\n')
127 fd.write('output_type;human\n')
128
129 try:
130 run = RunChecks([], config_path)
131
132 with caplog.at_level(logging.ERROR):
133 run.run_healthcheck()
134
135 assert "contains parsing errors" in caplog.text
136
137 finally:
138 os.remove(config_path)