-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor(plugins): Move jinja filter code for arista.avd.status_rende…
…r to PyAVD (#4142) Co-authored-by: Claus Holbech <[email protected]> Co-authored-by: Guillaume Mulocher <[email protected]>
- Loading branch information
1 parent
abf7650
commit 5d6858b
Showing
7 changed files
with
67 additions
and
79 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
12 changes: 0 additions & 12 deletions
12
ansible_collections/arista/avd/tests/unit/filters/filter_utils.py
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
ansible_collections/arista/avd/tests/unit/filters/test_markdown_rendering.py
This file was deleted.
Oops, something went wrong.
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
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,32 @@ | ||
# Copyright (c) 2023-2024 Arista Networks, Inc. | ||
# Use of this source code is governed by the Apache License 2.0 | ||
# that can be found in the LICENSE file. | ||
from __future__ import annotations | ||
|
||
|
||
def status_render(state_string, rendering): | ||
""" | ||
status_render Convert Text to EMOJI code | ||
Parameters | ||
---------- | ||
state_string : str | ||
Text to convert in EMOJI | ||
rendering : string | ||
Markdown Flavor to use for Emoji rendering. | ||
Returns | ||
------- | ||
str | ||
Value to render in markdown | ||
""" | ||
# STATIC EMOJI CODE | ||
GH_CODE = {} | ||
# Github MD code for Emoji checked box | ||
GH_CODE["PASS"] = ":white_check_mark:" | ||
# GH MD code for Emoji Fail | ||
GH_CODE["FAIL"] = ":x:" | ||
|
||
if rendering == "github": | ||
return GH_CODE[state_string.upper()] | ||
return state_string |
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
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,16 @@ | ||
# Copyright (c) 2023-2024 Arista Networks, Inc. | ||
# Use of this source code is governed by the Apache License 2.0 | ||
# that can be found in the LICENSE file. | ||
from __future__ import annotations | ||
|
||
import pytest | ||
from pyavd.j2filters.status_render import status_render | ||
|
||
STATE_STRINGS = [("PASS", "github", ":white_check_mark:"), ("fail", "github", ":x:"), ("FAIL", "test", "FAIL")] | ||
|
||
|
||
class TestMarkdownRenderingFilter: | ||
@pytest.mark.parametrize("state_string, rendering, markdown_code", STATE_STRINGS) | ||
def test_status_render_valid(self, state_string, rendering, markdown_code): | ||
resp = status_render(state_string, rendering) | ||
assert resp == markdown_code |