Only main and action_sort coverage left. And some big refactoring on sort. And a recursive function. And a check on destination.
This commit is contained in:
parent
df46468b43
commit
36d0c0c30d
|
|
@ -151,3 +151,4 @@ cython_debug/
|
|||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
.idea/
|
||||
cancel*
|
||||
/noconf.yaml
|
||||
|
|
|
|||
|
|
@ -111,19 +111,21 @@ def action_sort(argsp):
|
|||
|
||||
|
||||
def action_list(argsp):
|
||||
logging.info("Listing operations")
|
||||
with open(argsp.config, 'r') as stream:
|
||||
try:
|
||||
config = yaml.load(stream, Loader=yaml.FullLoader)
|
||||
except yaml.YAMLError as exc:
|
||||
logging.error(exc)
|
||||
sys.exit(1)
|
||||
if argsp.verbose:
|
||||
rich.print(config["operations"])
|
||||
else:
|
||||
for line in config["operations"].keys():
|
||||
rich.print(line)
|
||||
|
||||
try:
|
||||
logging.info("Listing operations")
|
||||
with open(argsp.config, 'r') as stream:
|
||||
config = yaml.safe_load(stream)
|
||||
if argsp.verbose:
|
||||
rich.print(config["operations"])
|
||||
else:
|
||||
for line in config["operations"].keys():
|
||||
rich.print(line)
|
||||
except TypeError:
|
||||
logging.critical("No operations found in config file {}".format(argsp.config))
|
||||
sys.exit(1)
|
||||
except FileNotFoundError:
|
||||
logging.critical("Config {} file not found".format(argsp.config))
|
||||
sys.exit(1)
|
||||
|
||||
# def action_help(argsp):
|
||||
# if argsp:
|
||||
|
|
|
|||
|
|
@ -124,13 +124,17 @@ def test_action_list(verbose, capsys):
|
|||
assert "condition" in capsys.readouterr().out
|
||||
|
||||
|
||||
# @pytest.mark.parametrize("args", [["--config=noconf.yaml","list"]])
|
||||
# def test_action_list_error(args, caplog, monkeypatch):
|
||||
#
|
||||
# with open("noconf.yaml", "w") as f:
|
||||
# f.write("Bad config =:/\n+3")
|
||||
#
|
||||
# args = criteriaSorter.parse_args(args)
|
||||
# with pytest.raises(SystemExit):
|
||||
# with caplog.at_level(logging.ERROR):
|
||||
# criteriaSorter.action_list(args)
|
||||
@pytest.mark.parametrize("args, error", [
|
||||
[["--config=noconf.yaml", "list"], "No operations found"],
|
||||
[["--config=unexisting_conf", "list"], "Config unexisting_conf file not found"],
|
||||
])
|
||||
def test_action_list_error(args, error, caplog, monkeypatch):
|
||||
|
||||
with open("noconf.yaml", "w") as f:
|
||||
f.write("Bad config =:/\n+3")
|
||||
|
||||
args = criteriaSorter.parse_args(args)
|
||||
with pytest.raises(SystemExit):
|
||||
with caplog.at_level(logging.ERROR):
|
||||
criteriaSorter.action_list(args)
|
||||
assert error in caplog.text
|
||||
|
|
|
|||
Loading…
Reference in New Issue