Пример #1
0
def test_diagnostics_element_general():
    diagnostics_element = diagnostics.GeneralDiagnosticsElement()
    assert diagnostics_element.ident == "general"
    assert diagnostics_element.title == "General"
    assert diagnostics_element.description == (
        "OS, Checkmk version and edition, Time, Core, " "Python version and paths, Architecture"
    )
Пример #2
0
def test_version_diagnostics_element(monkeypatch, tmp_path):
    tmppath = Path(tmp_path).joinpath("tmp")

    version_diagnostics_element = diagnostics.GeneralDiagnosticsElement()
    assert version_diagnostics_element.ident == "general"

    filepath = version_diagnostics_element.add_or_get_file(tmppath)
    assert filepath == tmppath.joinpath("general.json")
    assert version_diagnostics_element.description == "General: OS, Checkmk version and edition, Time, Core, Python version and paths"

    info_keys = [
        "time",
        "os",
        "version",
        "edition",
        "core",
        "python_version",
        "python_paths",
    ]
    assert sorted(json.loads(filepath.open().read()).keys()) == sorted(info_keys)
Пример #3
0
def test_diagnostics_element_general_content(tmp_path, _collectors):
    diagnostics_element = diagnostics.GeneralDiagnosticsElement()
    tmppath = Path(tmp_path).joinpath("tmp")
    filepath = next(diagnostics_element.add_or_get_files(tmppath, _collectors))

    assert isinstance(filepath, Path)
    assert filepath == tmppath.joinpath("general.json")

    info_keys = [
        "time",
        "os",
        "version",
        "edition",
        "core",
        "python_version",
        "python_paths",
        "arch",
    ]
    content = json.loads(filepath.open().read())

    assert sorted(content.keys()) == sorted(info_keys)