-
Notifications
You must be signed in to change notification settings - Fork 203
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.generate_lac…
…p_id to PyAVD
- Loading branch information
1 parent
55f18c4
commit 31d7a9d
Showing
7 changed files
with
69 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
18 changes: 18 additions & 0 deletions
18
python-avd/tests/pyavd/j2filters/test_markdown_rendering.py
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,18 @@ | ||
# 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 absolute_import, division, print_function | ||
|
||
__metaclass__ = type | ||
|
||
import pytest | ||
from pyavd.j2filters.markdown_rendering import status_render | ||
|
||
STATE_STRINGS = [("PASS", "github", ":white_check_mark:"), ("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 |