Skip to content

Commit e2640da

Browse files
committed
templates: Store emojis in dictionaries
Store waived/status emojis in dictionaries, keyed by the corresponding values, to make it possible to enumerate them. Might be a good idea to expose the similar mappings from the OO module to templates instead, later.
1 parent ec731d9 commit e2640da

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

kcidb/templates/test.j2

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,38 @@
11
{# Test macros #}
22

3+
{# Waived value emojis in order of decreasing priority #}
4+
{% set WAIVED_EMOJIS = {
5+
false: "",
6+
true: "🚧",
7+
none: "❓",
8+
} %}
9+
10+
{# Status value emojis in order of decreasing priority #}
11+
{% set STATUS_EMOJIS = {
12+
"FAIL": "❌",
13+
"ERROR": "💥",
14+
"PASS": "✅",
15+
"DONE": "🆗",
16+
"SKIP": "⏩",
17+
none: "❓",
18+
} %}
19+
20+
{# Combined waived and status values emojis in order of decreasing priority #}
21+
{% set WAIVED_STATUS_EMOJIS = {} %}
22+
{% for waived, waived_emoji in WAIVED_EMOJIS.items() %}
23+
{% for status, status_emoji in STATUS_EMOJIS.items() %}
24+
{% set _ = WAIVED_STATUS_EMOJIS.__setitem__(
25+
(waived, status), waived_emoji + status_emoji
26+
) %}
27+
{% endfor %}
28+
{% endfor %}
29+
330
{% macro status_emoji(status) %}
4-
{{- "💥" if status == "ERROR" else
5-
"❌" if status == "FAIL" else
6-
"✅" if status == "PASS" else
7-
"🆗" if status == "DONE" else
8-
"⏩" if status == "SKIP" else
9-
"❓" -}}
31+
{{- STATUS_EMOJI[status] -}}
1032
{% endmacro %}
1133

1234
{% macro waived_emoji(waived) %}
13-
{{- "🚧" if waived is true else
14-
"" if waived is false else
15-
"❓" -}}
35+
{{- WAIVED_EMOJI(waived) -}}
1636
{% endmacro %}
1737

1838
{% macro status_name(status) %}
@@ -24,7 +44,7 @@
2444
{% endmacro %}
2545

2646
{% macro waived_status_emoji(waived, status) %}
27-
{{- waived_emoji(waived) + status_emoji(status) -}}
47+
{{- WAIVED_STATUS_EMOJIS[(waived, status)] -}}
2848
{% endmacro %}
2949

3050
{% macro waived_status_badge(waived, status) %}

0 commit comments

Comments
 (0)