def test_pylint_checks():
    base_path = pylint_cmk.get_test_dir()

    f = file(base_path + "/cmk-checks.py", "w")

    # add the modules
    for path in pylint_cmk.ordered_module_files():
        pylint_cmk.add_file(f, path)

    # Now add the checks
    for path in pylint_cmk.check_files(repo_path() + "/checks"):
        pylint_cmk.add_file(f, path)

    # Also add inventory plugins
    for path in pylint_cmk.check_files(repo_path() + "/inventory"):
        pylint_cmk.add_file(f, path)

    # Also add bakery plugins
    for path in pylint_cmk.check_files(os.path.realpath(repo_path()
                                       + "/../cmc/agents/bakery")):
        pylint_cmk.add_file(f, path)

    f.close()

    exit_code = pylint_cmk.run_pylint(base_path, cleanup_test_dir=True)
    assert exit_code == 0, "PyLint found an error in checks, inventory " \
                           "or agent bakery plugins"
Beispiel #2
0
def test_pylint_checks():
    base_path = pylint_cmk.get_test_dir()

    f = file(base_path + "/cmk-checks.py", "w")

    # add the modules
    for path in pylint_cmk.ordered_module_files():
        pylint_cmk.add_file(f, path)

    # Now add the checks
    for path in pylint_cmk.check_files(repo_path() + "/checks"):
        pylint_cmk.add_file(f, path)

    # Also add inventory plugins
    for path in pylint_cmk.check_files(repo_path() + "/inventory"):
        pylint_cmk.add_file(f, path)

    # Also add bakery plugins
    for path in pylint_cmk.check_files(cmc_path() + "/agents/bakery"):
        pylint_cmk.add_file(f, path)

    f.close()

    exit_code = pylint_cmk.run_pylint(base_path, cleanup_test_dir=True)
    assert exit_code == 0, "PyLint found an error in checks, inventory " \
                           "or agent bakery plugins"
def test_pylint_modules():
    base_path = pylint_cmk.get_test_dir()

    f = file(base_path + "/cmk-modules.py", "w")
    for path in pylint_cmk.ordered_module_files():
        pylint_cmk.add_file(f, path)
    f.close()

    exit_code = pylint_cmk.run_pylint(base_path, cleanup_test_dir=True)
    assert exit_code == 0, "PyLint found an error in modules"
def test_pylint_modules():
    base_path = pylint_cmk.get_test_dir()

    f = file(base_path + "/cmk-modules.py", "w")
    for path in pylint_cmk.ordered_module_files():
        pylint_cmk.add_file(f, path)
    f.close()

    exit_code = pylint_cmk.run_pylint(base_path, cleanup_test_dir=True)
    assert exit_code == 0, "PyLint found an error in modules"
Beispiel #5
0
def test_pylint_web():
    base_path = pylint_cmk.get_test_dir()

    # Make compiled files import eachother by default
    sys.path.insert(0, base_path)

    modules = glob.glob(cmk_path() + "/web/htdocs/*.py") \
            + glob.glob(cmc_path() + "/web/htdocs/*.py") \
            + glob.glob(cme_path() + "/web/htdocs/*.py")

    for module in modules:
        print("Copy %s to test directory" % module)
        f = open(base_path + "/" + os.path.basename(module), "w")
        pylint_cmk.add_file(f, module)
        f.close()

    # Move the whole plugins code to their modules, then
    # run pylint only on the modules
    for plugin_dir in get_web_plugin_dirs():
        files = get_plugin_files(plugin_dir)

        for plugin_file, plugin_base in files:
            plugin_path = plugin_base + "/" + plugin_file

            if plugin_file.startswith('.'):
                continue
            elif plugin_dir in ["icons", "perfometer"]:
                module_name = "views"
            elif plugin_dir == "pages":
                module_name = "modules"
            else:
                module_name = plugin_dir

            print("[%s] add %s" % (module_name, plugin_path))
            module = file(base_path + "/" + module_name + ".py", "a")
            pylint_cmk.add_file(module, plugin_path)
            module.close()

    exit_code = pylint_cmk.run_pylint(base_path, cleanup_test_dir=True)
    assert exit_code == 0, "PyLint found an error in the web code"
Beispiel #6
0
def test_pylint_web():
    base_path = pylint_cmk.get_test_dir()

    # Make compiled files import eachother by default
    sys.path.insert(0, base_path)

    modules = glob.glob(cmk_path() + "/web/htdocs/*.py") \
            + glob.glob(cmc_path() + "/web/htdocs/*.py")

    for module in modules:
        print("Copy %s to test directory" % module)
        f = open(base_path + "/" + os.path.basename(module), "w")
        pylint_cmk.add_file(f, module)
        f.close()

    # Move the whole plugins code to their modules, then
    # run pylint only on the modules
    for plugin_dir in get_web_plugin_dirs():
        files = get_plugin_files(plugin_dir)

        for plugin_file, plugin_base in files:
            plugin_path = plugin_base +"/"+plugin_file

            if plugin_file.startswith('.'):
                continue
            elif plugin_dir in ["icons","perfometer"]:
                module_name = "views"
            elif plugin_dir == "pages":
                module_name = "modules"
            else:
                module_name = plugin_dir

            print("[%s] add %s" % (module_name, plugin_path))
            module = file(base_path + "/" + module_name + ".py", "a")
            pylint_cmk.add_file(module, plugin_path)
            module.close()

    exit_code = pylint_cmk.run_pylint(base_path, cleanup_test_dir=True)
    assert exit_code == 0, "PyLint found an error in the web code"