test_check_runner.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:monitoring-scripts 作者: CntoDev 项目源码 文件源码
def test_wait(mocker, config):  # pylint: disable=W0621
    """Assert runner waits before re-running the monitoring script"""

    mock_execution = mocker.Mock()
    mock_execution.returncode = Codes.CRITICAL.value

    mocker.patch('subprocess.run', return_value=mock_execution)
    mocker.patch('cachetclient.cachet.Components.put')
    time_sleep = mocker.patch('time.sleep')

    n_retries = 5
    d_interval = 10

    with pytest.raises(SystemExit):
        unit.main(script=mocker.Mock(), component_id=99, config_file=config, retries=n_retries,
                  interval=d_interval)

    expected_calls = [call(10), call(10), call(10), call(10), call(10)]

    assert time_sleep.call_args_list == expected_calls
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号