aboutsummaryrefslogtreecommitdiffstats
path: root/unit_tests/odl
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2016-10-19 20:30:29 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2016-10-20 17:26:39 +0200
commitcc1fb066aeae936a97bcace5cb853d2e5470bb87 (patch)
treeba7d196f2009d87e6665b4ae973cf8cce3e8d884 /unit_tests/odl
parent7ab6390b446b6219c9b8f4b0924a74746f22bba5 (diff)
Cover KeyError in ODLTestCases.run()
It simply tests if run returns EX_RUN_ERROR when a mandatory env var is unset (for instance SDN_CONTROLLER_IP in case of apex). Change-Id: Ib172975d84eb0953dd13bad32506bbd750ec4b8d Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'unit_tests/odl')
-rw-r--r--unit_tests/odl/test_odl.py35
1 files changed, 28 insertions, 7 deletions
diff --git a/unit_tests/odl/test_odl.py b/unit_tests/odl/test_odl.py
index e943dcaf4..76732593e 100644
--- a/unit_tests/odl/test_odl.py
+++ b/unit_tests/odl/test_odl.py
@@ -35,8 +35,9 @@ class ODLTestCasesTesting(unittest.TestCase):
_odl_password = "admin"
def setUp(self):
- if "INSTALLER_TYPE" in os.environ:
- del os.environ["INSTALLER_TYPE"]
+ for var in ("INSTALLER_TYPE", "SDN_CONTROLLER", "SDN_CONTROLLER_IP"):
+ if var in os.environ:
+ del os.environ[var]
os.environ["OS_USERNAME"] = self._os_username
os.environ["OS_PASSWORD"] = self._os_password
os.environ["OS_TENANT_NAME"] = self._os_tenantname
@@ -63,11 +64,6 @@ class ODLTestCasesTesting(unittest.TestCase):
def test_set_robotframework_vars(self, args):
self.assertTrue(self.test.set_robotframework_vars())
- def _test_run_missing_env_var(self, var):
- del os.environ[var]
- self.assertEqual(self.test.run(),
- TestCasesBase.TestCasesBase.EX_RUN_ERROR)
-
@classmethod
def _fake_url_for(cls, service_type='identity', **kwargs):
if service_type == 'identity':
@@ -274,6 +270,11 @@ class ODLTestCasesTesting(unittest.TestCase):
mock.patch.object(self.test, 'parse_results'):
self._test_main(TestCasesBase.TestCasesBase.EX_OK, *args)
+ def _test_run_missing_env_var(self, var):
+ del os.environ[var]
+ self.assertEqual(self.test.run(),
+ TestCasesBase.TestCasesBase.EX_RUN_ERROR)
+
def _test_run(self, status=TestCasesBase.TestCasesBase.EX_OK,
exception=None, odlip="127.0.0.3", odlwebport="8080"):
with mock.patch('functest.utils.openstack_utils.get_keystone_client',
@@ -314,6 +315,12 @@ class ODLTestCasesTesting(unittest.TestCase):
odlip=self._sdn_controller_ip,
odlwebport=self._odl_webport)
+ def test_run_missing_sdn_controller_ip(self):
+ with mock.patch('functest.utils.openstack_utils.get_keystone_client',
+ return_value=self._get_fake_keystone_client()):
+ self.assertEqual(self.test.run(),
+ TestCasesBase.TestCasesBase.EX_RUN_ERROR)
+
def test_run_without_installer_type(self):
os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
self._test_run(TestCasesBase.TestCasesBase.EX_OK,
@@ -325,12 +332,26 @@ class ODLTestCasesTesting(unittest.TestCase):
self._test_run(TestCasesBase.TestCasesBase.EX_OK,
odlip=self._neutron_ip, odlwebport='8282')
+ def test_run_apex_missing_sdn_controller_ip(self):
+ with mock.patch('functest.utils.openstack_utils.get_keystone_client',
+ return_value=self._get_fake_keystone_client()):
+ os.environ["INSTALLER_TYPE"] = "apex"
+ self.assertEqual(self.test.run(),
+ TestCasesBase.TestCasesBase.EX_RUN_ERROR)
+
def test_run_apex(self):
os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
os.environ["INSTALLER_TYPE"] = "apex"
self._test_run(TestCasesBase.TestCasesBase.EX_OK,
odlip=self._sdn_controller_ip, odlwebport='8181')
+ def test_run_joid_missing_sdn_controller(self):
+ with mock.patch('functest.utils.openstack_utils.get_keystone_client',
+ return_value=self._get_fake_keystone_client()):
+ os.environ["INSTALLER_TYPE"] = "joid"
+ self.assertEqual(self.test.run(),
+ TestCasesBase.TestCasesBase.EX_RUN_ERROR)
+
def test_run_joid(self):
os.environ["SDN_CONTROLLER"] = self._sdn_controller_ip
os.environ["INSTALLER_TYPE"] = "joid"