Migrate tests/integration/ssh/test_jinja_filters.py to pytest

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2022-08-26 20:11:11 +01:00 committed by Pedro Algarvio
parent b767b52b16
commit 8c56caec7b
4 changed files with 29 additions and 29 deletions

View file

@ -196,9 +196,9 @@ salt/(client/ssh/.+|cli/ssh\.py):
- integration.cli.test_custom_module
- pytests.integration.ssh.test_deploy
- pytests.integration.ssh.test_grains
- integration.ssh.test_jinja_filters
- pytests.integration.ssh.test_mine
- pytests.integration.ssh.test_master
- pytests.integration.ssh.test_jinja_filters
- pytests.integration.ssh.test_pillar
- pytests.integration.ssh.test_raw
- integration.ssh.test_state
@ -303,8 +303,8 @@ salt/utils/schedule.py:
salt/utils/vt.py:
- integration.cli.test_custom_module
- pytests.integration.ssh.test_grains
- integration.ssh.test_jinja_filters
- pytests.integration.ssh.test_mine
- pytests.integration.ssh.test_jinja_filters
- pytests.integration.ssh.test_pillar
- pytests.integration.ssh.test_raw
- integration.ssh.test_state

View file

@ -1,26 +0,0 @@
import platform
import pytest
from tests.support.case import SSHCase
class SSHJinjaFiltersTest(SSHCase):
"""
testing Jinja filters are available via state system & salt-ssh
"""
@pytest.mark.slow_test
def test_dateutils_strftime(self):
"""
test jinja filter datautils.strftime
"""
if "debian-9" in platform.platform().lower():
pytest.skip("This test is broken on debian 9, skipping")
arg = self._arg_str("state.sls", ["jinja_filters.dateutils_strftime"])
ret = self.run_ssh(arg)
import salt.utils.json
ret = salt.utils.json.loads(ret)["localhost"]
self.assertIn("module_|-test_|-test.echo_|-run", ret)
self.assertIn("ret", ret["module_|-test_|-test.echo_|-run"]["changes"])

View file

@ -0,0 +1,27 @@
import pytest
from saltfactories.utils.functional import StateResult
pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
]
def test_dateutils_strftime(salt_master, salt_ssh_cli):
"""
test jinja filter datautils.strftime
"""
sls_contents = """
{% set result = none | strftime('%Y-%m-%d') %}
test:
module.run:
- name: test.echo
- text: {{ result }}
"""
with salt_master.state_tree.base.temp_file("dateutils.sls", sls_contents):
ret = salt_ssh_cli.run("state.sls", "dateutils")
assert ret.returncode == 0
staterun = StateResult(ret.data)
assert staterun.result is True
assert staterun.changes
assert "ret" in staterun.changes

View file

@ -166,7 +166,6 @@ class BadTestModuleNamesTestCase(TestCase):
"integration.spm.test_repo",
"integration.ssh.test_deploy",
"integration.ssh.test_grains",
"integration.ssh.test_jinja_filters",
"integration.ssh.test_master",
"integration.ssh.test_mine",
"integration.ssh.test_pillar",