mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Updated test case to install from a requirements file.
This commit is contained in:
parent
612a4f0c5f
commit
20c45fbb6d
@ -195,6 +195,7 @@ class PipStateTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
|
||||
)
|
||||
)
|
||||
|
||||
# Using the package name.
|
||||
try:
|
||||
ret = self.run_state(
|
||||
'pip.installed', name='pep8', runas=username, bin_env=venv_dir
|
||||
@ -212,6 +213,42 @@ class PipStateTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
|
||||
finally:
|
||||
if os.path.isdir(venv_dir):
|
||||
shutil.rmtree(venv_dir)
|
||||
|
||||
# Using a requirements file
|
||||
venv_create = self.run_function(
|
||||
'virtualenv.create', [venv_dir], runas=username
|
||||
)
|
||||
if venv_create['retcode'] > 0:
|
||||
self.skipTest(
|
||||
'Failed to create testcase virtual environment: {0}'.format(
|
||||
ret
|
||||
)
|
||||
)
|
||||
req_filename = os.path.join(
|
||||
integration.TMP_STATE_TREE, 'issue-6912-requirements.txt'
|
||||
)
|
||||
with open(req_filename, 'wb') as f:
|
||||
f.write('pep8')
|
||||
|
||||
try:
|
||||
ret = self.run_state(
|
||||
'pip.installed', name='', runas=username, bin_env=venv_dir,
|
||||
requirements='salt://issue-6912-requirements.txt'
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
uinfo = pwd.getpwnam(username)
|
||||
for globmatch in (os.path.join(venv_dir, '**', 'pep8*'),
|
||||
os.path.join(venv_dir, '*', '**', 'pep8*'),
|
||||
os.path.join(venv_dir, '*', '*', '**', 'pep8*')):
|
||||
for path in glob.glob(globmatch):
|
||||
self.assertEqual(
|
||||
uinfo.pw_uid, os.stat(path).st_uid
|
||||
)
|
||||
|
||||
finally:
|
||||
if os.path.isdir(venv_dir):
|
||||
shutil.rmtree(venv_dir)
|
||||
os.unlink(req_filename)
|
||||
# <---- Using runas --------------------------------------------------
|
||||
|
||||
# ----- Using user -------------------------------------------------->
|
||||
@ -225,6 +262,7 @@ class PipStateTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
|
||||
)
|
||||
)
|
||||
|
||||
# Using the package name
|
||||
try:
|
||||
ret = self.run_state(
|
||||
'pip.installed', name='pep8', user=username, bin_env=venv_dir
|
||||
@ -242,6 +280,42 @@ class PipStateTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
|
||||
finally:
|
||||
if os.path.isdir(venv_dir):
|
||||
shutil.rmtree(venv_dir)
|
||||
|
||||
# Using a requirements file
|
||||
venv_create = self.run_function(
|
||||
'virtualenv.create', [venv_dir], runas=username
|
||||
)
|
||||
if venv_create['retcode'] > 0:
|
||||
self.skipTest(
|
||||
'Failed to create testcase virtual environment: {0}'.format(
|
||||
ret
|
||||
)
|
||||
)
|
||||
req_filename = os.path.join(
|
||||
integration.TMP_STATE_TREE, 'issue-6912-requirements.txt'
|
||||
)
|
||||
with open(req_filename, 'wb') as f:
|
||||
f.write('pep8')
|
||||
|
||||
try:
|
||||
ret = self.run_state(
|
||||
'pip.installed', name='', user=username, bin_env=venv_dir,
|
||||
requirements='salt://issue-6912-requirements.txt'
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
uinfo = pwd.getpwnam(username)
|
||||
for globmatch in (os.path.join(venv_dir, '**', 'pep8*'),
|
||||
os.path.join(venv_dir, '*', '**', 'pep8*'),
|
||||
os.path.join(venv_dir, '*', '*', '**', 'pep8*')):
|
||||
for path in glob.glob(globmatch):
|
||||
self.assertEqual(
|
||||
uinfo.pw_uid, os.stat(path).st_uid
|
||||
)
|
||||
|
||||
finally:
|
||||
if os.path.isdir(venv_dir):
|
||||
shutil.rmtree(venv_dir)
|
||||
os.unlink(req_filename)
|
||||
# <---- Using user ---------------------------------------------------
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user