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

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2022-08-24 16:27:18 +01:00 committed by Pedro Algarvio
parent 8ca6bb29f7
commit 5160ea4284
3 changed files with 33 additions and 34 deletions

View file

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

View file

@ -1,31 +0,0 @@
import os
import shutil
import pytest
import salt.utils.platform
from tests.support.case import SSHCase
from tests.support.unit import skipIf
@skipIf(salt.utils.platform.is_windows(), "salt-ssh not available on Windows")
class SSHMineTest(SSHCase):
"""
testing salt-ssh with mine
"""
@pytest.mark.slow_test
def test_ssh_mine_get(self):
"""
test salt-ssh with mine
"""
ret = self.run_function("mine.get", ["localhost test.arg"], wipe=False)
self.assertEqual(ret["localhost"]["args"], ["itworked"])
def tearDown(self):
"""
make sure to clean up any old ssh directories
"""
salt_dir = self.run_function("config.get", ["thin_dir"], wipe=False)
if os.path.exists(salt_dir):
shutil.rmtree(salt_dir)

View file

@ -0,0 +1,31 @@
import shutil
import pytest
pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
]
@pytest.fixture(autouse=True)
def thin_dir(salt_ssh_cli):
try:
yield
finally:
ret = salt_ssh_cli.run("config.get", "thin_dir")
assert ret.returncode == 0
thin_dir_path = ret.data
shutil.rmtree(thin_dir_path, ignore_errors=True)
def test_ssh_mine_get(salt_ssh_cli):
"""
test salt-ssh with mine
"""
ret = salt_ssh_cli.run("mine.get", "localhost", "test.arg")
assert ret.returncode == 0
assert ret.data
assert "localhost" in ret.data
assert "args" in ret.data["localhost"]
assert ret.data["localhost"]["args"] == ["itworked"]