Пример #1
0
def test_check_diskstat_dict(params, disk, exp_res):
    exp_res = exp_res.copy()
    value_store: Dict[str, Any] = {}

    assert (list(
        diskstat.check_diskstat_dict(params=params,
                                     disk=disk,
                                     value_store=value_store,
                                     this_time=time.time())) == exp_res)

    if exp_res:
        exp_res = [
            Result(state=state.OK,
                   notice="All values averaged over 5 minutes 0 seconds"),
            *exp_res,
        ]

    assert (list(
        diskstat.check_diskstat_dict(
            params=({
                **params, "average": 300
            }),
            disk=disk,
            value_store=value_store,
            this_time=time.time(),
        ), ) == exp_res)
Пример #2
0
def test_check_diskstat_dict(params, disk, exp_res):
    value_store: type_defs.ValueStore = {}

    assert list(diskstat.check_diskstat_dict(params, disk, value_store)) == exp_res

    if exp_res:
        exp_res[0] = Result(
            state=exp_res[0].state,
            summary="5 minutes 0 seconds average: " + exp_res[0].summary,
        )

    assert list(
        diskstat.check_diskstat_dict(type_defs.Parameters({
            **params, 'average': 300
        },), disk, value_store),) == exp_res
Пример #3
0
def test_check_diskstat_dict(params, disk, exp_res):
    with value_store.context('plugin', 'item'):  # type: ignore
        # we use {**disk} here because check_diskstat_dict pops items
        assert list(diskstat.check_diskstat_dict(params, {**disk}, get_value_store())) == exp_res

        if exp_res:
            exp_res[0] = Result(
                state=exp_res[0].state,
                summary="5 minutes 0 seconds average: " + exp_res[0].summary,
            )

        assert list(
            diskstat.check_diskstat_dict(type_defs.Parameters({
                **params, 'average': 300
            },), disk, get_value_store()),) == exp_res
Пример #4
0
def test_check_diskstat_dict(params, disk, exp_res):
    value_store: Dict[str, Any] = {}

    assert list(
        diskstat.check_diskstat_dict(params=params,
                                     disk=disk,
                                     value_store=value_store,
                                     this_time=time.time())) == exp_res

    if exp_res:
        exp_res.insert(
            0, Result(state=state.OK, notice="All values averaged over 5 minutes 0 seconds"))

    assert list(
        diskstat.check_diskstat_dict(
            params=({
                **params, 'average': 300
            }),
            disk=disk,
            value_store=value_store,
            this_time=time.time(),
        ),) == exp_res