Updated test case to install from a requirements file.

This commit is contained in:
Pedro Algarvio 2013-08-29 20:21:23 +00:00
parent 612a4f0c5f
commit 20c45fbb6d

View File

@ -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 ---------------------------------------------------