Skip to content

Commit

Permalink
[test] fix test_ensure_delay_when_tilde_in_custom_schedule
Browse files Browse the repository at this point in the history
This commit relax constrains on possible test failure

    @staticmethod
    def test_ensure_delay_when_tilde_in_custom_schedule(mocker, capsys):
        svcname = "pytest"
        mocker.patch.dict(os.environ, {"OSVC_DETACHED": "1"})
        with capsys.disabled():
            assert Mgr()(argv=["-s", svcname, "create", "--kw", "status_schedule=~08:01-09:59"]) == 0
            assert Mgr()(argv=["-s", svcname, "print", "schedule"]) == 0
        next_runs = set()
        for i in range(4):
            assert Mgr()(argv=["-s", svcname, "print", "schedule", "--local", "--format", "json"]) == 0
            action = get_action(json.loads(capsys.readouterr().out), "status")
            next_runs.add(action["next_run"])
>       assert len(next_runs) > 3
E       assert 3 > 3
E        +  where 3 = len({1700042310.0, 1700042326.0, 1700042331.0})
  • Loading branch information
cgalibern committed Nov 16, 2023
1 parent 6fc89b0 commit eabdbad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions opensvc/tests/commands/svc/test_schedule.py
Expand Up @@ -66,11 +66,11 @@ def test_ensure_delay_when_tilde_in_custom_schedule(mocker, capsys):
assert Mgr()(argv=["-s", svcname, "create", "--kw", "status_schedule=~08:01-09:59"]) == 0
assert Mgr()(argv=["-s", svcname, "print", "schedule"]) == 0
next_runs = set()
for i in range(4):
for i in range(6):
assert Mgr()(argv=["-s", svcname, "print", "schedule", "--local", "--format", "json"]) == 0
action = get_action(json.loads(capsys.readouterr().out), "status")
next_runs.add(action["next_run"])
assert len(next_runs) > 3
assert len(next_runs) > 2, "'print schedule --local' called 6 times should propose at leat 2 != next_run"

@staticmethod
def test_ensure_next_run_is_fixed_when_no_tilde_in_custom_schedule(mocker, capsys):
Expand Down

0 comments on commit eabdbad

Please sign in to comment.