Exemple #1
0
def resolve_user_data_metadata_name(user_data, key, value):
    config_resolvenames = config_global.get_attr('status.resolvenames')
    config_resolvenames = "" if config_resolvenames is None else str(config_resolvenames).lower()
    if config_resolvenames == 'false':
        return None

    resolver = None
    is_id = None
    name = None
    if key == 'result id':
        name = value
        resolver = Resolver("/test-results", rest_crud.base_endpoint_with_workspace)
    elif key == 'settings id':
        name = value
        resolver = Resolver("/tests", rest_crud.base_endpoint_with_workspace)
    elif key == 'workspace id':
        name = value
        resolver = Resolver("/workspaces", rest_crud.base_endpoint)
        is_id = True
    if resolver is not None:
        if is_id is None:
            is_id = tools.is_id(name)
        entity = tools.get_named_or_id(name, is_id, resolver)
        return entity["name"]
    return None
Exemple #2
0
def unregister(name, function):
    hook = config_global.get_attr("$hooks." + name)
    if hook:
        hook.remove(function)
        if hook:
            config_global.set_attr("$hooks." + name, list(hook))
        else:
            config_global.set_attr(__prefix + "." + name, None)
Exemple #3
0
def trig(name, *args, **kwargs):
    functions_to_trig = config_global.get_attr(__prefix + "." + name)
    if functions_to_trig:
        for function_to_trig in functions_to_trig:
            split = function_to_trig.split('.')
            module = __import__(split[0])
            for comp in split[1:]:
                module = getattr(module, comp)
            module(*args, **kwargs)
    def test_docker_install_hooks(self):
        config_global.reset()

        # settings is empty
        assert None is config_global.get_attr("$hooks.test.start", None)
        assert None is config_global.get_attr("$hooks.test.stop", None)

        # install Hooks
        docker_lib.install()
        assert "neoload_cli_lib.docker_lib.hook_test_start" in config_global.get_attr(
            "$hooks.test.start", [])
        assert "neoload_cli_lib.docker_lib.hook_test_stop" in config_global.get_attr(
            "$hooks.test.stop", [])

        # remove Hooks
        docker_lib.uninstall()
        assert "neoload_cli_lib.docker_lib.hook_test_start" not in config_global.get_attr(
            "$hooks.test.start", [])
        assert "neoload_cli_lib.docker_lib.hook_test_stop" not in config_global.get_attr(
            "$hooks.test.stop", [])
Exemple #5
0
def get_setting(key):
    return config_global.get_attr(key, default_settings.get(key))
Exemple #6
0
def is_user_interactive():
    return get_boolean_value_from_env(__nl_interactive_env_var, False) or config_global.get_attr("interactive", False)
Exemple #7
0
def is_registered(name, function):
    hook = config_global.get_attr(__prefix + "." + name)
    return hook and function in hook
Exemple #8
0
def register(name, function):
    hook = config_global.get_attr(__prefix + "." + name)
    hook_set = set(hook) if hook else set()

    hook_set.add(function)
    config_global.set_attr(__prefix + "." + name, list(hook_set))