|
| 1 | +# Copyright: 2024 MoinMoin:UlrichB |
| 2 | +# License: GNU GPL v2 (or any later version), see LICENSE.txt for details. |
| 3 | + |
| 4 | +""" |
| 5 | +Test for macros.ShowIcons |
| 6 | +""" |
| 7 | + |
| 8 | +from moin.macros.ShowIcons import Macro |
| 9 | + |
| 10 | + |
| 11 | +def test_ShowIconsMacro(): |
| 12 | + """Call ShowIcons macro and test output""" |
| 13 | + test_icons = ["admon-note", "angry", "biggrin", "frown", "moin-rss", "smile3", "star_off"] |
| 14 | + expected_namespace = "{http://moinmo.in/namespaces/page}" |
| 15 | + expected_tags = set(f"{expected_namespace}{el_name}" for el_name in ["table", "table-header", "table-row"]) |
| 16 | + expected_texts = set(f"<<Icon({icon_name}.png)>>" for icon_name in test_icons) |
| 17 | + expected_paths = set(f"/static/img/icons/{icon_name}.png" for icon_name in test_icons) |
| 18 | + macro_obj = Macro() |
| 19 | + macro_out = macro_obj.macro("content", None, "page_url", "alternative") |
| 20 | + result_tags = set() |
| 21 | + result_texts = set() |
| 22 | + result_paths = set() |
| 23 | + for node in macro_out.iter_elements_tree(): |
| 24 | + if getattr(node, "tag"): |
| 25 | + result_tags.add(str(getattr(node, "tag"))) |
| 26 | + if getattr(node, "text"): |
| 27 | + result_texts.add(getattr(node, "text")) |
| 28 | + if getattr(node, "attrib"): |
| 29 | + result_paths.update(getattr(node, "attrib").values()) |
| 30 | + assert expected_tags.issubset(result_tags) |
| 31 | + assert expected_texts.issubset(result_texts) |
| 32 | + assert expected_paths.issubset(result_paths) |
0 commit comments