Skip to content

Commit

Permalink
Ensure that the correct value of jid_inclue is passed if the argument…
Browse files Browse the repository at this point in the history
… is included in the passed keyword arguments
  • Loading branch information
garethgreenaway authored and s0undt3ch committed Sep 30, 2023
1 parent 872293b commit 727c3fe
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
3 changes: 1 addition & 2 deletions salt/modules/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
32 changes: 32 additions & 0 deletions tests/pytests/unit/modules/test_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 727c3fe

Please sign in to comment.