Exemplo n.º 1
0
def test_missing_catalog_entries_of_man_pages():
    catalog_titles = set(man_pages.catalog_titles.keys())
    found_catalog_entries_from_man_pages = set()
    for name in man_pages.all_man_pages():
        man_page = man_pages.load_man_page(name)
        found_catalog_entries_from_man_pages |= set(man_page['header']['catalog'].split("/"))
    missing_catalog_entries = found_catalog_entries_from_man_pages - catalog_titles
    assert missing_catalog_entries == set(), "Found missing catalog entries: %s" % ", ".join(
        sorted(missing_catalog_entries))
Exemplo n.º 2
0
def get_all_pages() -> ManPages:
    base_dirs = [
        Path(cpe_path(), "checkman"),
        Path(cmk_path(), "checkman"),
    ]
    return {
        name: man_pages.load_man_page(name, base_dirs)
        for name in man_pages.all_man_pages(base_dirs)
    }
Exemplo n.º 3
0
def test_missing_catalog_entries_of_man_pages(all_pages: ManPages) -> None:
    found_catalog_entries_from_man_pages: set[str] = set()
    for name in man_pages.all_man_pages():
        man_page = all_pages[name]
        assert man_page is not None
        found_catalog_entries_from_man_pages.update(man_page.catalog)
    missing_catalog_entries = found_catalog_entries_from_man_pages - set(
        man_pages.CATALOG_TITLES)
    assert not missing_catalog_entries
Exemplo n.º 4
0
def test_manpage_catalog_headers():
    for name, path in man_pages.all_man_pages().items():
        try:
            parsed = man_pages._parse_man_page_header(name, Path(path))
        except Exception as e:
            if cmk.utils.debug.enabled():
                raise
            parsed = man_pages._create_fallback_man_page(name, Path(path), e)

        assert parsed.get("catalog"), "Did not find \"catalog:\" header in man page \"%s\"" % name
Exemplo n.º 5
0
def test_missing_catalog_entries_of_man_pages(all_pages) -> None:
    catalog_titles = set(man_pages.catalog_titles.keys())
    found_catalog_entries_from_man_pages = set()
    for name in man_pages.all_man_pages():
        man_page = all_pages[name]
        assert man_page is not None
        found_catalog_entries_from_man_pages |= set(
            man_page["header"]["catalog"].split("/"))
    missing_catalog_entries = found_catalog_entries_from_man_pages - catalog_titles
    assert missing_catalog_entries == set(
    ), "Found missing catalog entries: %s" % ", ".join(
        sorted(missing_catalog_entries))
Exemplo n.º 6
0
def test_find_missing_manpages():
    all_check_manuals = man_pages.all_man_pages()

    import cmk_base.check_api as check_api
    config.load_all_checks(check_api.get_check_api_context)
    checks_sorted = sorted([ (name, entry) for (name, entry) in config.check_info.items()
                      if not _is_pure_section_declaration(entry) ] + \
       [ ("check_" + name, entry) for (name, entry) in config.active_check_info.items() ])
    assert len(checks_sorted) > 1000

    for check_plugin_name, check in checks_sorted:
        assert check_plugin_name in all_check_manuals, "Manpage missing: %s" % check_plugin_name
Exemplo n.º 7
0
def test_all_man_pages(tmpdir):
    tmpdir.join(".asd").write("")
    tmpdir.join("asd~").write("")
    tmpdir.join("if").write("")

    pages = man_pages.all_man_pages()

    assert len(pages) > 1241
    assert ".asd" not in pages
    assert "asd~" not in pages

    assert pages["if"] == "%s/if" % tmpdir
    assert pages["if64"] == "%s/checkman/if64" % cmk_path()
Exemplo n.º 8
0
def test_all_man_pages(tmp_path):
    (tmp_path / ".asd").write_text(u"", encoding="utf-8")
    (tmp_path / "asd~").write_text(u"", encoding="utf-8")
    (tmp_path / "if").write_text(u"", encoding="utf-8")

    pages = man_pages.all_man_pages()

    assert len(pages) > 1241
    assert ".asd" not in pages
    assert "asd~" not in pages

    assert pages["if"] == str(tmp_path / "if")
    assert pages["if64"] == "%s/checkman/if64" % cmk_path()
Exemplo n.º 9
0
def test_find_missing_manpages():
    all_check_manuals = man_pages.all_man_pages()

    import cmk_base.check_api as check_api
    config.load_all_checks(check_api.get_check_api_context)
    checks_sorted = sorted([ (name, entry) for (name, entry) in config.check_info.items()
                      if not _is_pure_section_declaration(entry) ] + \
       [ ("check_" + name, entry) for (name, entry) in config.active_check_info.items() ])
    assert len(checks_sorted) > 1000

    for check_plugin_name, check in checks_sorted:
        if check_plugin_name in ["labels", "esx_systeminfo"]:
            continue  # this check's discovery function can only create labels, never a service
        assert check_plugin_name in all_check_manuals, "Manpage missing: %s" % check_plugin_name
Exemplo n.º 10
0
def test_load_all_man_pages():
    for name in man_pages.all_man_pages().keys():
        man_page = man_pages.load_man_page(name)
        assert type(man_page) == dict
        _check_man_page_structure(man_page)
Exemplo n.º 11
0
def test_manpage_files():
    manuals = man_pages.all_man_pages()
    assert len(manuals) > 1000
Exemplo n.º 12
0
def test_load_all_man_pages():
    for name in man_pages.all_man_pages():
        man_page = man_pages.load_man_page(name)
        assert isinstance(man_page, dict)
        _check_man_page_structure(man_page)
Exemplo n.º 13
0
def _get_all_pages():
    return {
        name: man_pages.load_man_page(name)
        for name in man_pages.all_man_pages()
    }
Exemplo n.º 14
0
def get_all_pages() -> ManPages:
    return {
        name: man_pages.load_man_page(name)
        for name in man_pages.all_man_pages()
    }