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
3 | 3 | |
4 | 4 | import argparse |
5 | 5 | import io |
6 | import logging | |
6 | 7 | import os |
7 | 8 | import tempfile |
8 | 9 | from contextlib import redirect_stdout |
103 | 104 | |
104 | 105 | finally: |
105 | 106 | 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) |