Skip to content

Commit

Permalink
Convert tests to proper unit tests, removing unnecessary dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpfleming committed Aug 2, 2023
1 parent 2d769b5 commit a3848f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 33 deletions.
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ python = "3.11"

[tool.hatch.envs.lint]
dependencies = [
"attrs", # needed for type-checking tests
"black",
"jinjanator", # needed for type-checking tests
"ruff",
"mypy",
"pytest", # needed for type-checking tests
Expand All @@ -111,7 +109,6 @@ lint-action = [
dependencies = [
"attrs",
"coverage[toml]",
"jinjanator",
"pytest",
"pytest-cov",
"pytest-icdiff",
Expand Down
48 changes: 18 additions & 30 deletions tests/test_plugin.py
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

0 comments on commit a3848f3

Please sign in to comment.