- self._test_main(testcase_base.TestcaseBase.EX_OK, *args)
-
- @mock.patch('os.remove', side_effect=OSError)
- @mock.patch('robot.run')
- @mock.patch('os.makedirs')
- def test_main_remove_oserror(self, *args):
- with mock.patch.object(self.test, 'set_robotframework_vars',
- return_value=True), \
- mock.patch.object(odl, 'open', mock.mock_open(),
- create=True), \
- mock.patch.object(self.test, 'parse_results'):
- self._test_main(testcase_base.TestcaseBase.EX_OK, *args)
-
- def _test_run_missing_env_var(self, var):
- with mock.patch('functest.utils.openstack_utils.get_endpoint',
- side_effect=self._fake_url_for):
- del os.environ[var]
- self.assertEqual(self.test.run(),
- testcase_base.TestcaseBase.EX_RUN_ERROR)
-
- def _test_run(self, status=testcase_base.TestcaseBase.EX_OK,
- exception=None, odlip="127.0.0.3", odlwebport="8080",
- odlrestconfport="8181"):
- with mock.patch('functest.utils.openstack_utils.get_endpoint',
- side_effect=self._fake_url_for):
- if exception:
- self.test.main = mock.Mock(side_effect=exception)
- else:
- self.test.main = mock.Mock(return_value=status)
- self.assertEqual(self.test.run(), status)
- self.test.main.assert_called_once_with(
- odl.ODLTests.default_suites,
- neutronip=self._neutron_ip,
- odlip=odlip, odlpassword=self._odl_password,
- odlrestconfport=odlrestconfport,
- odlusername=self._odl_username, odlwebport=odlwebport,
- osauthurl=self._os_auth_url,
- ospassword=self._os_password, ostenantname=self._os_tenantname,
- osusername=self._os_username)
-
- def _test_run_defining_multiple_suites(
- self, suites,
- status=testcase_base.TestcaseBase.EX_OK,
- exception=None, odlip="127.0.0.3", odlwebport="8080",
- odlrestconfport="8181"):
- with mock.patch('functest.utils.openstack_utils.get_endpoint',
- side_effect=self._fake_url_for):
- if exception:
- self.test.main = mock.Mock(side_effect=exception)
- else:
- self.test.main = mock.Mock(return_value=status)
- self.assertEqual(self.test.run(suites=suites), status)
- self.test.main.assert_called_once_with(
- suites,
- neutronip=self._neutron_ip,
- odlip=odlip, odlpassword=self._odl_password,
- odlrestconfport=odlrestconfport,
- odlusername=self._odl_username, odlwebport=odlwebport,
- osauthurl=self._os_auth_url,
- ospassword=self._os_password, ostenantname=self._os_tenantname,
- osusername=self._os_username)
-
- def test_run_exception(self):
- with mock.patch('functest.utils.openstack_utils.get_endpoint',
+ self._test_run_suites(testcase.TestCase.EX_OK, *args)
+
+
+class ODLRunTesting(ODLTesting):
+
+ """The class testing ODLTests.run()."""
+ # pylint: disable=missing-docstring
+
+ @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_no_env_var(self, var, *args):
+ del os.environ[var]
+ 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'
+ odlwebport = kwargs['odlwebport'] if 'odlwebport' in kwargs else '8080'
+ odlrestconfport = (kwargs['odlrestconfport']
+ if 'odlrestconfport' in kwargs else '8181')
+ if exception:
+ self.test.run_suites = mock.Mock(side_effect=exception)
+ else:
+ self.test.run_suites = mock.Mock(return_value=status)
+ self.assertEqual(self.test.run(), status)
+ self.test.run_suites.assert_called_once_with(
+ odl.ODLTests.default_suites, neutronurl=self._neutron_url,
+ odlip=odlip, odlpassword=self._odl_password,
+ odlrestconfport=odlrestconfport, odlusername=self._odl_username,
+ odlwebport=odlwebport, osauthurl=self._os_auth_url,
+ ospassword=self._os_password, osprojectname=self._os_projectname,
+ osusername=self._os_username,
+ osprojectdomainname=self._os_projectdomainname,
+ osuserdomainname=self._os_userdomainname)
+ 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_multiple_suites(self, suites,
+ status=testcase.TestCase.EX_OK, *args, **kwargs):
+ odlip = kwargs['odlip'] if 'odlip' in kwargs else '127.0.0.3'
+ odlwebport = kwargs['odlwebport'] if 'odlwebport' in kwargs else '8080'
+ odlrestconfport = (kwargs['odlrestconfport']
+ if 'odlrestconfport' in kwargs else '8181')
+ self.test.run_suites = mock.Mock(return_value=status)
+ self.assertEqual(self.test.run(suites=suites), status)
+ self.test.run_suites.assert_called_once_with(
+ suites, neutronurl=self._neutron_url, odlip=odlip,
+ odlpassword=self._odl_password, odlrestconfport=odlrestconfport,
+ odlusername=self._odl_username, odlwebport=odlwebport,
+ osauthurl=self._os_auth_url, ospassword=self._os_password,
+ osprojectname=self._os_projectname, osusername=self._os_username,
+ osprojectdomainname=self._os_projectdomainname,
+ osuserdomainname=self._os_userdomainname)
+ args[0].assert_called_once_with()
+ args[1].assert_called_once_with(mock.ANY, 'network')
+
+ def test_exc(self):
+ with mock.patch('snaps.openstack.utils.keystone_utils.get_endpoint',