Adding unit test of setting config path for "tempest run"
It will check the positive and negative case for sending data and sending no data to ensure path variable is set properly. Partially-Implements: blueprint tempest-cli-unit-test-coverage Related-Bug: #1783751 Change-Id: I996ec912ed39ecc3c3ca293c257126b910b3e958
This commit is contained in:
parent
79159f80a9
commit
321c85c87c
|
@ -24,11 +24,14 @@ import mock
|
|||
import six
|
||||
|
||||
from tempest.cmd import run
|
||||
from tempest import config
|
||||
from tempest.tests import base
|
||||
|
||||
DEVNULL = open(os.devnull, 'wb')
|
||||
atexit.register(DEVNULL.close)
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
class TestTempestRun(base.TestCase):
|
||||
|
||||
|
@ -146,6 +149,35 @@ class TestRunReturnCode(base.TestCase):
|
|||
'--regex', 'passing'], 0)
|
||||
|
||||
|
||||
class TestConfigPathCheck(base.TestCase):
|
||||
def setUp(self):
|
||||
super(TestConfigPathCheck, self).setUp()
|
||||
self.run_cmd = run.TempestRun(None, None)
|
||||
|
||||
def test_tempest_run_set_config_path(self):
|
||||
# Note: (mbindlish) This test is created for the bug id: 1783751
|
||||
# Checking TEMPEST_CONFIG_DIR and TEMPEST_CONFIG is actually
|
||||
# getting set in os environment when some data has passed to
|
||||
# set the environment.
|
||||
|
||||
self.run_cmd._set_env("/fakedir/fakefile")
|
||||
self.assertEqual("/fakedir/fakefile", CONF._path)
|
||||
self.assertIn('TEMPEST_CONFIG_DIR', os.environ)
|
||||
self.assertEqual("/fakedir/fakefile",
|
||||
os.path.join(os.environ['TEMPEST_CONFIG_DIR'],
|
||||
os.environ['TEMPEST_CONFIG']))
|
||||
|
||||
def test_tempest_run_set_config_no_path(self):
|
||||
# Note: (mbindlish) This test is created for the bug id: 1783751
|
||||
# Checking TEMPEST_CONFIG_DIR and TEMPEST_CONFIG should have no value
|
||||
# in os environment when no data has passed to set the environment.
|
||||
|
||||
self.run_cmd._set_env("")
|
||||
self.assertFalse(CONF._path)
|
||||
self.assertNotIn('TEMPEST_CONFIG_DIR', os.environ)
|
||||
self.assertNotIn('TEMPEST_CONFIG', os.environ)
|
||||
|
||||
|
||||
class TestTakeAction(base.TestCase):
|
||||
def test_workspace_not_registered(self):
|
||||
class Exception_(Exception):
|
||||
|
|
Loading…
Reference in New Issue