def test_vg_free(pool, command_returns, raises, returns):
    def execute_module(module_name, *_):
        if module_name != "command":
            raise ValueError("not expecting module " + module_name)
        return command_returns

    check = DockerStorage(execute_module)
    if raises:
        with pytest.raises(OpenShiftCheckException) as err:
            check.get_vg_free(pool)
        assert raises in str(err.value)
    else:
        ret = check.get_vg_free(pool)
        assert ret == returns
def test_vg_free(pool, command_returns, raises, returns):
    def execute_module(module_name, *_):
        if module_name != "command":
            raise ValueError("not expecting module " + module_name)
        return command_returns

    check = DockerStorage(execute_module)
    if raises:
        with pytest.raises(OpenShiftCheckException) as err:
            check.get_vg_free(pool)
        assert raises in str(err.value)
    else:
        ret = check.get_vg_free(pool)
        assert ret == returns
def test_dm_usage(task_vars, driver_status, vg_free, success, expect_msg):
    check = DockerStorage(None, task_vars)
    check.get_vg_free = lambda pool: vg_free
    result = check.check_dm_usage(driver_status)
    result_success = not result.get("failed")

    assert result_success is success
    for msg in expect_msg:
        assert msg in result["msg"]
def test_dm_usage(task_vars, driver_status, vg_free, success, expect_msg):
    check = DockerStorage(None, task_vars)
    check.get_vg_free = lambda pool: vg_free
    result = check.check_dm_usage(driver_status)
    result_success = not result.get("failed")

    assert result_success is success
    for msg in expect_msg:
        assert msg in result["msg"]