summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-02-26 11:52:15 +0100
committerCédric Ollivier <cedric.ollivier@orange.com>2018-02-26 11:53:10 +0100
commit70886a190335f02f1c7ed1d9c50823f978b291b1 (patch)
treed700f598c6ee1ed54476ba9efb03333f639a98a8
parentd262b55a1e29b1202cd584f859d2d221d9addb8c (diff)
Raise exceptions when SDN_CONTROLLER_IP is None
Change-Id: Ia0d00a6b3c4c4936dc10602e838f507beea0c592 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
-rw-r--r--functest/opnfv_tests/sdn/odl/odl.py1
-rw-r--r--functest/tests/unit/odl/test_odl.py17
2 files changed, 14 insertions, 4 deletions
diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py
index 7283be57f..f5e07ad3d 100644
--- a/functest/opnfv_tests/sdn/odl/odl.py
+++ b/functest/opnfv_tests/sdn/odl/odl.py
@@ -190,6 +190,7 @@ class ODLTests(robotframework.RobotFramework):
kwargs['odlrestconfport'] = '8087'
else:
kwargs['odlip'] = env.get('SDN_CONTROLLER_IP')
+ assert kwargs['odlip']
except KeyError as ex:
self.__logger.error("Cannot run ODL testcases. "
"Please check env var: "
diff --git a/functest/tests/unit/odl/test_odl.py b/functest/tests/unit/odl/test_odl.py
index aa31703b8..65784ae53 100644
--- a/functest/tests/unit/odl/test_odl.py
+++ b/functest/tests/unit/odl/test_odl.py
@@ -282,6 +282,15 @@ class ODLRunTesting(ODLTesting):
return_value=ODLTesting._neutron_url)
@mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
'get_credentials')
+ def _test_missing_value(self, *args):
+ self.assertEqual(self.test.run(), testcase.TestCase.EX_RUN_ERROR)
+ args[0].assert_called_once_with()
+ args[1].assert_called_once_with(mock.ANY, 'network')
+
+ @mock.patch('snaps.openstack.utils.keystone_utils.get_endpoint',
+ return_value=ODLTesting._neutron_url)
+ @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
+ 'get_credentials')
def _test_run(self, status=testcase.TestCase.EX_OK,
exception=None, *args, **kwargs):
odlip = kwargs['odlip'] if 'odlip' in kwargs else '127.0.0.3'
@@ -361,7 +370,7 @@ class ODLRunTesting(ODLTesting):
odlwebport=self._odl_webport)
def test_no_sdn_controller_ip(self):
- self.assertEqual(self.test.run(), testcase.TestCase.EX_RUN_ERROR)
+ self._test_missing_value()
def test_without_installer_type(self):
os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
@@ -386,7 +395,7 @@ class ODLRunTesting(ODLTesting):
def test_apex_no_controller_ip(self):
os.environ["INSTALLER_TYPE"] = "apex"
- self.assertEqual(self.test.run(), testcase.TestCase.EX_RUN_ERROR)
+ self._test_missing_value()
def test_apex(self):
os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
@@ -397,7 +406,7 @@ class ODLRunTesting(ODLTesting):
def test_netvirt_no_controller_ip(self):
os.environ["INSTALLER_TYPE"] = "netvirt"
- self.assertEqual(self.test.run(), testcase.TestCase.EX_RUN_ERROR)
+ self._test_missing_value()
def test_netvirt(self):
os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
@@ -414,7 +423,7 @@ class ODLRunTesting(ODLTesting):
def test_daisy_no_controller_ip(self):
os.environ["INSTALLER_TYPE"] = "daisy"
- self.assertEqual(self.test.run(), testcase.TestCase.EX_RUN_ERROR)
+ self._test_missing_value()
def test_daisy(self):
os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip