Module: check_mk
Branch: master
Commit: ab22be4e0636c2f2792f67d83d06dbd8e2731420
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ab22be4e0636c2…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jan 22 16:49:30 2019 +0100
Fixed legacy and dynamic inventory painter registration
Change-Id: I3834ff6b6dacd5a379729ae638321f5c7fd1a0ce
---
cmk/gui/plugins/views/inventory.py | 2 +-
cmk/gui/plugins/views/utils.py | 2 +-
tests/unit/cmk/gui/test_views.py | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/cmk/gui/plugins/views/inventory.py b/cmk/gui/plugins/views/inventory.py
index ea876f4..60377d8 100644
--- a/cmk/gui/plugins/views/inventory.py
+++ b/cmk/gui/plugins/views/inventory.py
@@ -171,7 +171,7 @@ def declare_inv_column(invpath, datatype, title, short=None):
"columns": ["host_inventory",
"host_structured_status"],
"options": ["show_internal_tree_paths"],
"load_inv": True,
- "paint": lambda self, row: paint_host_inventory_tree(row, invpath),
+ "paint": lambda row: paint_host_inventory_tree(row, invpath),
"sorter": name,
}
if short:
diff --git a/cmk/gui/plugins/views/utils.py b/cmk/gui/plugins/views/utils.py
index fecf6e6..a4bef1c 100644
--- a/cmk/gui/plugins/views/utils.py
+++ b/cmk/gui/plugins/views/utils.py
@@ -770,7 +770,7 @@ def register_painter(ident, spec):
"ident": property(lambda s: s._ident),
"title": property(lambda s: s._spec["title"]),
"columns": property(lambda s: s._spec["columns"]),
- "render": spec["paint"],
+ "render": lambda self, row, cell: spec["paint"](row),
"short_title": property(lambda s: s._spec.get("short",
s.title)),
"group_by": property(lambda s: s._spec.get("groupby")),
"parameters": property(lambda s: s._spec.get("params")),
diff --git a/tests/unit/cmk/gui/test_views.py b/tests/unit/cmk/gui/test_views.py
index 199e9c0..64bf126 100644
--- a/tests/unit/cmk/gui/test_views.py
+++ b/tests/unit/cmk/gui/test_views.py
@@ -4031,8 +4031,8 @@ def test_legacy_register_painter(monkeypatch):
monkeypatch.setattr(cmk.gui.plugins.views.utils, "painter_registry",
cmk.gui.plugins.views.utils.PainterRegistry())
- def rendr():
- pass
+ def rendr(row):
+ return "xyz"
cmk.gui.plugins.views.utils.register_painter(
"abc", {
@@ -4054,4 +4054,4 @@ def test_legacy_register_painter(monkeypatch):
assert painter.sorter == "aaaa"
assert painter.painter_options == ["opt1"]
assert painter.printable is False
- assert painter.render.__name__ == rendr.__name__
+ assert painter.render(row={}, cell=None) == "xyz"