Raised Coverage to 86%
This commit is contained in:
parent
ec3c38855b
commit
9723597ff0
|
|
@ -65,9 +65,9 @@ class ConfigLoader:
|
|||
else:
|
||||
self.loaded_conf[name].update(yaml.safe_load(f))
|
||||
error_mngr.log_message(f"Warning: {name} is already in {self.loaded_conf}", level='WARNING')
|
||||
except yaml.parser.ParserError as e:
|
||||
except BaseException as e:
|
||||
error_mngr.log_message(f'Error parsing in file {basename} at {filepath}.', level='CRITICAL')
|
||||
error_mngr.log_exception(yaml.parser.ParserError(e), level='CRITICAL')
|
||||
error_mngr.log_exception(str(e), level='CRITICAL')
|
||||
|
||||
def load_from_folder(self, folder):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -125,6 +125,6 @@ class ExportManager:
|
|||
return ExportResponse(start, end)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == '__main__': # pragma: no cover
|
||||
herbert = ExportManager(cnoifg=None, templates=None)
|
||||
herbert._get_template(ExportRequest('b', 'c', 'class="hugues"'))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import os
|
||||
|
||||
import yaml
|
||||
|
||||
import bootstraparse.modules.config as config
|
||||
import pytest
|
||||
import tempfile
|
||||
|
|
@ -13,9 +15,12 @@ configs = {
|
|||
"user/config/glossary.yaml": '{"glossary": {"test_glossary": "test_parser"}}',
|
||||
"user/config/custom_template.yaml": '{"custom_template": {"test_template": "test_parser"}}',
|
||||
}
|
||||
|
||||
bad_configs = {
|
||||
"user/bad_config/bad_config.yaml": '{"custom_template": {"test_template": "test_parser',
|
||||
}
|
||||
user_conf = os.path.join(temp_folder.name, "user/config")
|
||||
app_conf = os.path.join(temp_folder.name, "app/configs")
|
||||
bad_conf = os.path.join(temp_folder.name, "user/bad_config")
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
|
@ -24,6 +29,10 @@ def make_false_configs():
|
|||
os.makedirs(os.path.dirname(os.path.join(temp_folder.name, file_name)), exist_ok=True)
|
||||
with open(os.path.join(temp_folder.name, file_name), "w") as f:
|
||||
f.write(content)
|
||||
for file_name, content in bad_configs.items():
|
||||
os.makedirs(os.path.dirname(os.path.join(temp_folder.name, file_name)), exist_ok=True)
|
||||
with open(os.path.join(temp_folder.name, file_name), "w") as f:
|
||||
f.write(content)
|
||||
|
||||
|
||||
def test_config_load():
|
||||
|
|
@ -56,3 +65,16 @@ def test_add_to_config():
|
|||
from_empty.load_from_file(os.path.join(app_conf, "aliases.yaml"))
|
||||
assert from_empty["aliases"] == {"aliases": {"test_alias": "test_parser"},
|
||||
"parser": {"name": "test_parser", "type": "test_parser"}}
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
from_empty.load_from_file(os.path.join(bad_conf, "bad_config.yaml"))
|
||||
|
||||
|
||||
def test_contains():
|
||||
usr_c = config.ConfigLoader(user_conf)
|
||||
assert "aliases" in usr_c
|
||||
|
||||
|
||||
def test_bad_type():
|
||||
with pytest.raises(SystemExit):
|
||||
config.ConfigLoader(1)
|
||||
|
|
|
|||
Loading…
Reference in New Issue