Ensure that the correct value of jid_inclue is passed if the argument is included in the passed keyword arguments

This commit is contained in:
Gareth J. Greenaway 2023-09-29 13:15:54 -07:00 committed by Pedro Algarvio
parent 872293bbb0
commit 727c3fe784
2 changed files with 33 additions and 2 deletions

View file

@ -521,8 +521,7 @@ def build_schedule_item(name, **kwargs):
else:
schedule[name]["enabled"] = True
if "jid_include" not in kwargs or kwargs["jid_include"]:
schedule[name]["jid_include"] = True
schedule[name]["jid_include"] = kwargs.get("jid_include", True)
if "splay" in kwargs:
if isinstance(kwargs["splay"], dict):

View file

@ -198,6 +198,38 @@ def test_build_schedule_item_invalid_jobs_args():
) == {"comment": comment2, "result": False}
def test_build_schedule_item_jid_include():
"""
Test build_schedule_item when jid_include is passed and not passed
"""
ret = schedule.build_schedule_item("job1", function="test.args", jid_include=False)
assert ret == {
"function": "test.args",
"maxrunning": 1,
"name": "job1",
"enabled": True,
"jid_include": False,
}
ret = schedule.build_schedule_item("job1", function="test.args", jid_include=True)
assert ret == {
"function": "test.args",
"maxrunning": 1,
"name": "job1",
"enabled": True,
"jid_include": True,
}
ret = schedule.build_schedule_item("job1", function="test.args")
assert ret == {
"function": "test.args",
"maxrunning": 1,
"name": "job1",
"enabled": True,
"jid_include": True,
}
# 'add' function tests: 1