-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests to verify tag group painter and sorter registration
Change-Id: I0653f34879e29afd0f628a54595b9ed0df12785d
- Loading branch information
1 parent
1fb2ff4
commit 1c6f4be
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (C) 2024 Checkmk GmbH - License: GNU General Public License v2 | ||
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and | ||
# conditions defined in the file COPYING, which is part of this source code package. | ||
|
||
import pytest | ||
|
||
from cmk.utils.tags import TagConfig, TagGroupID, TagID | ||
|
||
from cmk.gui.config import active_config | ||
from cmk.gui.painter.v0 import base | ||
from cmk.gui.views import host_tag_plugins | ||
|
||
|
||
@pytest.mark.usefixtures("load_config") | ||
def test_host_tag_painter_registration(monkeypatch: pytest.MonkeyPatch) -> None: | ||
monkeypatch.setattr( | ||
host_tag_plugins, "painter_registry", painter_registry := base.PainterRegistry() | ||
) | ||
monkeypatch.setattr(base, "painter_registry", painter_registry) | ||
|
||
with monkeypatch.context() as m: | ||
m.setattr( | ||
active_config, | ||
"tags", | ||
TagConfig.from_config( | ||
{ | ||
"aux_tags": [], | ||
"tag_groups": [ | ||
{ | ||
"id": TagGroupID("whoot"), | ||
"topic": "Blubberei", | ||
"tags": [ | ||
{ | ||
"aux_tags": [], | ||
"id": TagID("bla"), | ||
"title": "Bla", | ||
}, | ||
], | ||
"title": "Whoot", | ||
}, | ||
], | ||
} | ||
), | ||
) | ||
host_tag_plugins.register_tag_plugins() | ||
assert "host_tag_whoot" in list(base.painter_registry.keys()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (C) 2024 Checkmk GmbH - License: GNU General Public License v2 | ||
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and | ||
# conditions defined in the file COPYING, which is part of this source code package. | ||
|
||
import pytest | ||
|
||
from cmk.utils.tags import TagConfig, TagGroupID, TagID | ||
|
||
from cmk.gui.config import active_config | ||
from cmk.gui.views import host_tag_plugins | ||
from cmk.gui.views.sorter import registry | ||
|
||
|
||
@pytest.mark.usefixtures("load_config") | ||
def test_host_tag_sorter_registration(monkeypatch: pytest.MonkeyPatch) -> None: | ||
monkeypatch.setattr( | ||
host_tag_plugins, "sorter_registry", sorter_registry := registry.SorterRegistry() | ||
) | ||
monkeypatch.setattr(registry, "sorter_registry", sorter_registry) | ||
|
||
with monkeypatch.context() as m: | ||
m.setattr( | ||
active_config, | ||
"tags", | ||
TagConfig.from_config( | ||
{ | ||
"aux_tags": [], | ||
"tag_groups": [ | ||
{ | ||
"id": TagGroupID("whoot"), | ||
"topic": "Blubberei", | ||
"tags": [ | ||
{ | ||
"aux_tags": [], | ||
"id": TagID("bla"), | ||
"title": "Bla", | ||
}, | ||
], | ||
"title": "Whoot", | ||
}, | ||
], | ||
} | ||
), | ||
) | ||
host_tag_plugins.register_tag_plugins() | ||
assert "host_tag_whoot" in list(registry.sorter_registry.keys()) |