mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Move setup tests to unit tests. Adjust.
This commit is contained in:
parent
a6f4995c63
commit
48e7e20e22
7 changed files with 158 additions and 141 deletions
|
@ -1 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
|
@ -1,57 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.integration.setup.test_bdist
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
"""
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
import salt.utils.path
|
||||
import salt.utils.platform
|
||||
from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.helpers import VirtualEnv, slowTest
|
||||
from tests.support.runtests import RUNTIME_VARS
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
|
||||
@skipIf(
|
||||
salt.utils.path.which_bin(KNOWN_BINARY_NAMES) is None, "virtualenv not installed"
|
||||
)
|
||||
class BdistSetupTest(ModuleCase):
|
||||
"""
|
||||
Tests for building and installing bdist_wheel packages
|
||||
"""
|
||||
|
||||
@slowTest
|
||||
def test_wheel_build(self):
|
||||
"""
|
||||
test building a bdist_wheel package
|
||||
"""
|
||||
# Let's create the testing virtualenv
|
||||
with VirtualEnv() as venv:
|
||||
ret = self.run_function(
|
||||
"cmd.run",
|
||||
[
|
||||
"{0} setup.py bdist_wheel --dist-dir={1}".format(
|
||||
venv.venv_python, venv.venv_dir
|
||||
)
|
||||
],
|
||||
cwd=RUNTIME_VARS.CODE_DIR,
|
||||
)
|
||||
|
||||
for _file in os.listdir(venv.venv_dir):
|
||||
if _file.endswith("whl"):
|
||||
whl = os.path.join(venv.venv_dir, _file)
|
||||
break
|
||||
|
||||
ret = self.run_function("pip.install", pkgs=whl, bin_env=venv.venv_dir)
|
||||
|
||||
# Let's ensure the version is correct
|
||||
pip_ver = self.run_function("pip.list", bin_env=venv.venv_dir).get("salt")
|
||||
whl_ver = [
|
||||
x for x in whl.split("/")[-1:][0].split("-") if re.search(r"^\d.\d*", x)
|
||||
][0]
|
||||
assert pip_ver == whl_ver.replace("_", "-")
|
|
@ -1,80 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.integration.setup.test_egg
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
"""
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
|
||||
import salt.utils.path
|
||||
import salt.utils.platform
|
||||
from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.helpers import VirtualEnv, destructiveTest, slowTest
|
||||
from tests.support.runtests import RUNTIME_VARS
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
|
||||
@destructiveTest
|
||||
@skipIf(
|
||||
salt.utils.path.which_bin(KNOWN_BINARY_NAMES) is None, "virtualenv not installed"
|
||||
)
|
||||
class EggSetupTest(ModuleCase):
|
||||
"""
|
||||
Tests for building and installing egg packages
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
# ensure we have a clean build dir
|
||||
self._clean_build()
|
||||
|
||||
def _clean_build(self):
|
||||
"""
|
||||
helper method to clean the build dir
|
||||
"""
|
||||
dirs = [
|
||||
os.path.join(RUNTIME_VARS.CODE_DIR, "build"),
|
||||
os.path.join(RUNTIME_VARS.CODE_DIR, "salt.egg-info"),
|
||||
os.path.join(RUNTIME_VARS.CODE_DIR, "dist"),
|
||||
]
|
||||
for _dir in dirs:
|
||||
if os.path.exists(_dir):
|
||||
shutil.rmtree(_dir)
|
||||
|
||||
@slowTest
|
||||
def test_egg_install(self):
|
||||
"""
|
||||
test installing an egg package
|
||||
"""
|
||||
# Let's create the testing virtualenv
|
||||
with VirtualEnv() as venv:
|
||||
ret = self.run_function(
|
||||
"cmd.run",
|
||||
[
|
||||
"{0} setup.py install --prefix={1}".format(
|
||||
venv.venv_python, venv.venv_dir
|
||||
)
|
||||
],
|
||||
cwd=RUNTIME_VARS.CODE_DIR,
|
||||
)
|
||||
self._clean_build()
|
||||
lib_dir = os.path.join(venv.venv_dir, "lib")
|
||||
for _dir in os.listdir(lib_dir):
|
||||
site_pkg = os.path.join(lib_dir, _dir, "site-packages")
|
||||
for _file in os.listdir(site_pkg):
|
||||
if _file.startswith("salt-"):
|
||||
egg = os.path.join(venv.venv_dir, _file)
|
||||
assert os.path.exists(
|
||||
os.path.join(site_pkg, _file, "salt", "_version.py")
|
||||
)
|
||||
break
|
||||
|
||||
# Let's ensure the version is correct
|
||||
pip_ver = self.run_function("pip.list", bin_env=venv.venv_dir).get("salt")
|
||||
egg_ver = [
|
||||
x for x in egg.split("/")[-1:][0].split("-") if re.search(r"^\d.\d*", x)
|
||||
][0]
|
||||
assert pip_ver == egg_ver.replace("_", "-")
|
|
@ -112,7 +112,6 @@ TEST_SUITES_UNORDERED = {
|
|||
"runners": {"display_name": "Runners", "path": "integration/runners"},
|
||||
"renderers": {"display_name": "Renderers", "path": "integration/renderers"},
|
||||
"returners": {"display_name": "Returners", "path": "integration/returners"},
|
||||
"setup": {"display_name": "Setup", "path": "integration/setup"},
|
||||
"ssh-int": {"display_name": "SSH Integration", "path": "integration/ssh"},
|
||||
"spm": {"display_name": "SPM", "path": "integration/spm"},
|
||||
"loader": {"display_name": "Loader", "path": "integration/loader"},
|
||||
|
|
70
tests/unit/setup/test_bdist.py
Normal file
70
tests/unit/setup/test_bdist.py
Normal file
|
@ -0,0 +1,70 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.integration.setup.test_bdist
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
"""
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
import salt.utils.path
|
||||
import salt.utils.platform
|
||||
from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES
|
||||
from tests.support.helpers import VirtualEnv, slowTest, with_tempdir
|
||||
from tests.support.runtests import RUNTIME_VARS
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@skipIf(
|
||||
salt.utils.path.which_bin(KNOWN_BINARY_NAMES) is None, "virtualenv not installed"
|
||||
)
|
||||
class BdistSetupTest(TestCase):
|
||||
"""
|
||||
Tests for building and installing bdist_wheel packages
|
||||
"""
|
||||
|
||||
@slowTest
|
||||
@with_tempdir()
|
||||
def test_wheel_build(self, tempdir):
|
||||
"""
|
||||
test building a bdist_wheel package
|
||||
"""
|
||||
# Let's create the testing virtualenv
|
||||
with VirtualEnv() as venv:
|
||||
venv.run(venv.venv_python, "setup.py", "clean", cwd=RUNTIME_VARS.CODE_DIR)
|
||||
venv.run(
|
||||
venv.venv_python,
|
||||
"setup.py",
|
||||
"bdist_wheel",
|
||||
"--dist-dir",
|
||||
tempdir,
|
||||
cwd=RUNTIME_VARS.CODE_DIR,
|
||||
)
|
||||
for _file in os.listdir(tempdir):
|
||||
if _file.endswith("whl"):
|
||||
whl = os.path.join(tempdir, _file)
|
||||
break
|
||||
|
||||
venv.install("--ignore-installed", whl)
|
||||
|
||||
# Let's ensure the version is correct
|
||||
cmd = venv.run(venv.venv_python, "-m", "pip", "list", "--format", "json")
|
||||
for details in json.loads(cmd.stdout):
|
||||
if details["name"] != "salt":
|
||||
continue
|
||||
pip_ver = details["version"]
|
||||
break
|
||||
else:
|
||||
self.fail("Salt was not found installed")
|
||||
whl_ver = [
|
||||
x for x in whl.split("/")[-1:][0].split("-") if re.search(r"^\d.\d*", x)
|
||||
][0]
|
||||
whl_ver_cmp = whl_ver.replace("_", "-")
|
||||
assert pip_ver == whl_ver.replace("_", "-"), "{} != {}".format(
|
||||
pip_ver, whl_ver_cmp
|
||||
)
|
86
tests/unit/setup/test_egg.py
Normal file
86
tests/unit/setup/test_egg.py
Normal file
|
@ -0,0 +1,86 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
tests.integration.setup.test_egg
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
"""
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
|
||||
import salt.utils.path
|
||||
import salt.utils.platform
|
||||
from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES
|
||||
from tests.support.helpers import VirtualEnv, slowTest, with_tempdir
|
||||
from tests.support.runtests import RUNTIME_VARS
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
|
||||
|
||||
@skipIf(
|
||||
salt.utils.path.which_bin(KNOWN_BINARY_NAMES) is None, "virtualenv not installed"
|
||||
)
|
||||
class EggSetupTest(TestCase):
|
||||
"""
|
||||
Tests for building and installing egg packages
|
||||
"""
|
||||
|
||||
@slowTest
|
||||
@with_tempdir()
|
||||
def test_egg_install(self, tempdir):
|
||||
"""
|
||||
test installing an egg package
|
||||
"""
|
||||
# Let's create the testing virtualenv
|
||||
with VirtualEnv() as venv:
|
||||
venv.run(venv.venv_python, "setup.py", "clean", cwd=RUNTIME_VARS.CODE_DIR)
|
||||
|
||||
# Setuptools installs pre-release packages if we don't pin to an exact version
|
||||
# Let's download and install requirements before, running salt's install test
|
||||
venv.run(
|
||||
venv.venv_python,
|
||||
"-m",
|
||||
"pip",
|
||||
"download",
|
||||
"--dest",
|
||||
tempdir,
|
||||
RUNTIME_VARS.CODE_DIR,
|
||||
)
|
||||
packages = []
|
||||
for fname in os.listdir(tempdir):
|
||||
packages.append(os.path.join(tempdir, fname))
|
||||
venv.install(*packages)
|
||||
|
||||
venv.run(
|
||||
venv.venv_python,
|
||||
"setup.py",
|
||||
"install",
|
||||
"--prefix",
|
||||
venv.venv_dir,
|
||||
cwd=RUNTIME_VARS.CODE_DIR,
|
||||
)
|
||||
venv.run(venv.venv_python, "setup.py", "clean", cwd=RUNTIME_VARS.CODE_DIR)
|
||||
lib_dir = os.path.join(venv.venv_dir, "lib")
|
||||
for _dir in os.listdir(lib_dir):
|
||||
site_pkg = os.path.join(lib_dir, _dir, "site-packages")
|
||||
for _file in os.listdir(site_pkg):
|
||||
if _file.startswith("salt-"):
|
||||
egg = os.path.join(venv.venv_dir, _file)
|
||||
assert os.path.exists(
|
||||
os.path.join(site_pkg, _file, "salt", "_version.py")
|
||||
)
|
||||
break
|
||||
|
||||
# Let's ensure the version is correct
|
||||
cmd = venv.run(venv.venv_python, "-m", "pip", "list", "--format", "json")
|
||||
for details in json.loads(cmd.stdout):
|
||||
if details["name"] != "salt":
|
||||
continue
|
||||
pip_ver = details["version"]
|
||||
break
|
||||
else:
|
||||
self.fail("Salt was not found installed")
|
||||
egg_ver = [
|
||||
x for x in egg.split("/")[-1:][0].split("-") if re.search(r"^\d.\d*", x)
|
||||
][0]
|
||||
assert pip_ver == egg_ver.replace("_", "-")
|
|
@ -174,8 +174,8 @@ class BadTestModuleNamesTestCase(TestCase):
|
|||
"integration.reactor.test_reactor",
|
||||
"integration.returners.test_noop_return",
|
||||
"integration.runners.test_runner_returns",
|
||||
"integration.setup.test_bdist",
|
||||
"integration.setup.test_egg",
|
||||
"unit.setup.test_bdist",
|
||||
"unit.setup.test_egg",
|
||||
"integration.shell.test_spm",
|
||||
"integration.shell.test_cp",
|
||||
"integration.shell.test_syndic",
|
||||
|
|
Loading…
Add table
Reference in a new issue