Skip to content

Commit

Permalink
Migrate tests/integration/modules/test_virtualenv_mod.py to functional
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
  • Loading branch information
s0undt3ch authored and Megan Wilhite committed Aug 23, 2022
1 parent 49c210f commit 1f78f9b
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 62 deletions.
62 changes: 0 additions & 62 deletions tests/integration/modules/test_virtualenv_mod.py

This file was deleted.

73 changes: 73 additions & 0 deletions tests/pytests/functional/modules/test_virtualenv_mod.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import shutil

import pytest

from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES

pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_if_binaries_missing(*KNOWN_BINARY_NAMES, check_all=False),
]


@pytest.fixture
def venv_dir(tmp_path):
return tmp_path / "venv"


@pytest.fixture
def virtualenv(modules):
return modules.virtualenv


def test_create_defaults(virtualenv, venv_dir):
"""
virtualenv.managed
"""
ret = virtualenv.create(str(venv_dir))
assert ret
assert "retcode" in ret
assert ret["retcode"] == 0
pip_binary = venv_dir / "bin" / "pip"
assert pip_binary.exists()


def test_site_packages(virtualenv, venv_dir, modules):
ret = virtualenv.create(str(venv_dir), system_site_packages=True)
assert ret
assert "retcode" in ret
assert ret["retcode"] == 0
pip_binary = venv_dir / "bin" / "pip"
with_site = modules.pip.freeze(bin_env=str(pip_binary))
shutil.rmtree(venv_dir)
ret = virtualenv.create(str(venv_dir))
assert ret
assert "retcode" in ret
assert ret["retcode"] == 0
without_site = modules.pip.freeze(bin_env=str(pip_binary))
assert with_site != without_site


def test_clear(virtualenv, venv_dir, modules):
ret = virtualenv.create(str(venv_dir))
assert ret
assert "retcode" in ret
assert ret["retcode"] == 0
pip_binary = venv_dir / "bin" / "pip"
modules.pip.install("pep8", bin_env=str(pip_binary))
ret = virtualenv.create(str(venv_dir), clear=True)
assert ret
assert "retcode" in ret
assert ret["retcode"] == 0
packages = modules.pip.list(prefix="pep8", bin_env=str(pip_binary))
assert "pep8" not in packages


def test_virtualenv_ver(virtualenv, venv_dir):
ret = virtualenv.create(str(venv_dir))
assert ret
assert "retcode" in ret
assert ret["retcode"] == 0
ret = virtualenv.virtualenv_ver(str(venv_dir))
assert isinstance(ret, tuple)
assert all([isinstance(x, int) for x in ret])

0 comments on commit 1f78f9b

Please sign in to comment.