-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert tests to proper unit tests, removing unnecessary dependencies.
- Loading branch information
Showing
2 changed files
with
18 additions
and
33 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
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 |
---|---|---|
@@ -1,37 +1,25 @@ | ||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
from jinjanator_plugin_ansible import plugin | ||
|
||
from jinjanator.cli import render_command | ||
|
||
def test_plugin_identity() -> None: | ||
result = plugin.plugin_identities() | ||
assert result.startswith("ansible") | ||
assert "ansible-core" in result | ||
|
||
def test_filter(tmp_path: Path) -> None: | ||
template_file = tmp_path / "template.j2" | ||
template_file.write_text("{{ name | to_uuid }}") | ||
data_file = tmp_path / "data.env" | ||
data_file.write_text("name=Bart") | ||
assert ( | ||
render_command( | ||
Path.cwd(), | ||
{}, | ||
None, | ||
["", str(template_file), str(data_file)], | ||
) | ||
== "7acd55fd-0779-54cc-a798-cdf367486926" | ||
) | ||
|
||
def test_plugin_filters() -> None: | ||
result = plugin.plugin_filters() | ||
assert "to_uuid" in result | ||
assert "union" in result | ||
assert "urldecode" in result | ||
assert "urlsplit" in result | ||
|
||
def test_test(tmp_path: Path) -> None: | ||
template_file = tmp_path / "template.j2" | ||
template_file.write_text("{% if ver is version('22.0', '>=') %}pass{% endif %}") | ||
data_file = tmp_path / "data.env" | ||
data_file.write_text("ver=23.2.0") | ||
assert ( | ||
render_command( | ||
Path.cwd(), | ||
{}, | ||
None, | ||
["", str(template_file), str(data_file)], | ||
) | ||
== "pass" | ||
) | ||
|
||
def test_plugin_tests() -> None: | ||
result = plugin.plugin_tests() | ||
assert "version_compare" in result | ||
assert "is_same_file" in result | ||
assert "contains" in result | ||
assert "uri" in result |