3 # Copyright (c) 2016 Orange and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 """Define the classes required to fully cover odl."""
18 from robot.errors import RobotError
20 from six.moves import urllib
21 from xtesting.core import testcase
23 from functest.opnfv_tests.sdn.odl import odl
25 __author__ = "Cedric Ollivier <cedric.ollivier@orange.com>"
28 class ODLTesting(unittest.TestCase):
30 """The super class which testing classes could inherit."""
31 # pylint: disable=missing-docstring
33 logging.disable(logging.CRITICAL)
35 _keystone_ip = "127.0.0.1"
36 _neutron_url = u"https://127.0.0.1:9696"
37 _neutron_id = u"dummy"
38 _sdn_controller_ip = "127.0.0.3"
39 _os_auth_url = "http://{}:5000/v3".format(_keystone_ip)
40 _os_projectname = "admin"
41 _os_username = "admin"
42 _os_password = "admin"
44 _odl_restconfport = "8181"
45 _odl_username = "admin"
46 _odl_password = "admin"
47 _os_userdomainname = 'Default'
48 _os_projectdomainname = 'Default'
49 _os_interface = "public"
52 for var in ("INSTALLER_TYPE", "SDN_CONTROLLER", "SDN_CONTROLLER_IP"):
55 os.environ["OS_AUTH_URL"] = self._os_auth_url
56 os.environ["OS_USERNAME"] = self._os_username
57 os.environ["OS_USER_DOMAIN_NAME"] = self._os_userdomainname
58 os.environ["OS_PASSWORD"] = self._os_password
59 os.environ["OS_PROJECT_NAME"] = self._os_projectname
60 os.environ["OS_PROJECT_DOMAIN_NAME"] = self._os_projectdomainname
61 os.environ["OS_PASSWORD"] = self._os_password
62 os.environ["OS_INTERFACE"] = self._os_interface
63 self.test = odl.ODLTests(case_name='odl', project_name='functest')
64 self.defaultargs = {'odlusername': self._odl_username,
65 'odlpassword': self._odl_password,
66 'neutronurl': "http://{}:9696".format(
68 'osauthurl': self._os_auth_url,
69 'osusername': self._os_username,
70 'osuserdomainname': self._os_userdomainname,
71 'osprojectname': self._os_projectname,
72 'osprojectdomainname': self._os_projectdomainname,
73 'ospassword': self._os_password,
74 'odlip': self._keystone_ip,
75 'odlwebport': self._odl_webport,
76 'odlrestconfport': self._odl_restconfport,
80 class ODLRobotTesting(ODLTesting):
82 """The class testing ODLTests.set_robotframework_vars()."""
83 # pylint: disable=missing-docstring
85 @mock.patch('fileinput.input', side_effect=Exception())
86 def test_set_vars_ko(self, mock_method):
87 self.assertFalse(self.test.set_robotframework_vars())
88 mock_method.assert_called_once_with(
89 os.path.join(odl.ODLTests.odl_test_repo,
90 'csit/variables/Variables.robot'), inplace=True)
92 @mock.patch('fileinput.input', return_value=[])
93 def test_set_vars_empty(self, mock_method):
94 self.assertTrue(self.test.set_robotframework_vars())
95 mock_method.assert_called_once_with(
96 os.path.join(odl.ODLTests.odl_test_repo,
97 'csit/variables/Variables.robot'), inplace=True)
99 @mock.patch('sys.stdout', new_callable=six.StringIO)
100 def _test_set_vars(self, msg1, msg2, *args):
101 line = mock.MagicMock()
102 line.__iter__.return_value = [msg1]
103 with mock.patch('fileinput.input', return_value=line) as mock_method:
104 self.assertTrue(self.test.set_robotframework_vars())
105 mock_method.assert_called_once_with(
106 os.path.join(odl.ODLTests.odl_test_repo,
107 'csit/variables/Variables.robot'), inplace=True)
108 self.assertEqual(args[0].getvalue(), "{}\n".format(msg2))
110 def test_set_vars_auth_default(self):
113 "@{AUTH} admin admin")
115 def test_set_vars_auth1(self):
120 @mock.patch('sys.stdout', new_callable=six.StringIO)
121 def test_set_vars_auth_foo(self, *args):
122 line = mock.MagicMock()
123 line.__iter__.return_value = ["@{AUTH} "]
124 with mock.patch('fileinput.input', return_value=line) as mock_method:
125 self.assertTrue(self.test.set_robotframework_vars('foo', 'bar'))
126 mock_method.assert_called_once_with(
127 os.path.join(odl.ODLTests.odl_test_repo,
128 'csit/variables/Variables.robot'), inplace=True)
134 class ODLMainTesting(ODLTesting):
136 """The class testing ODLTests.run_suites()."""
137 # pylint: disable=missing-docstring
139 def _get_run_suites_kwargs(self, key=None):
140 kwargs = {'odlusername': self._odl_username,
141 'odlpassword': self._odl_password,
142 'neutronurl': self._neutron_url,
143 'osauthurl': self._os_auth_url,
144 'osusername': self._os_username,
145 'osuserdomainname': self._os_userdomainname,
146 'osprojectname': self._os_projectname,
147 'osprojectdomainname': self._os_projectdomainname,
148 'ospassword': self._os_password,
149 'odlip': self._sdn_controller_ip,
150 'odlwebport': self._odl_webport,
151 'odlrestconfport': self._odl_restconfport}
156 def _test_run_suites(self, status, *args):
157 kwargs = self._get_run_suites_kwargs()
158 self.assertEqual(self.test.run_suites(**kwargs), status)
160 args[0].assert_called_once_with(self.test.odl_variables_file)
163 'KEYSTONEURL:{}://{}'.format(
164 urllib.parse.urlparse(self._os_auth_url).scheme,
165 urllib.parse.urlparse(self._os_auth_url).netloc),
166 'NEUTRONURL:{}'.format(self._neutron_url),
167 'OS_AUTH_URL:"{}"'.format(self._os_auth_url),
168 'OSUSERNAME:"{}"'.format(self._os_username),
169 'OSUSERDOMAINNAME:"{}"'.format(self._os_userdomainname),
170 'OSTENANTNAME:"{}"'.format(self._os_projectname),
171 'OSPROJECTDOMAINNAME:"{}"'.format(self._os_projectdomainname),
172 'OSPASSWORD:"{}"'.format(self._os_password),
173 'ODL_SYSTEM_IP:{}'.format(self._sdn_controller_ip),
174 'PORT:{}'.format(self._odl_webport),
175 'RESTCONFPORT:{}'.format(self._odl_restconfport)]
176 args[1].assert_called_once_with(
177 odl.ODLTests.basic_suite_dir, odl.ODLTests.neutron_suite_dir,
180 output=os.path.join(self.test.res_dir, 'output.xml'),
181 report='NONE', stdout=mock.ANY, variable=variable,
184 def _test_no_keyword(self, key):
185 kwargs = self._get_run_suites_kwargs(key)
186 self.assertEqual(self.test.run_suites(**kwargs),
187 testcase.TestCase.EX_RUN_ERROR)
189 def test_no_odlusername(self):
190 self._test_no_keyword('odlusername')
192 def test_no_odlpassword(self):
193 self._test_no_keyword('odlpassword')
195 def test_no_neutronurl(self):
196 self._test_no_keyword('neutronurl')
198 def test_no_osauthurl(self):
199 self._test_no_keyword('osauthurl')
201 def test_no_osusername(self):
202 self._test_no_keyword('osusername')
204 def test_no_osprojectname(self):
205 self._test_no_keyword('osprojectname')
207 def test_no_ospassword(self):
208 self._test_no_keyword('ospassword')
210 def test_no_odlip(self):
211 self._test_no_keyword('odlip')
213 def test_no_odlwebport(self):
214 self._test_no_keyword('odlwebport')
216 def test_no_odlrestconfport(self):
217 self._test_no_keyword('odlrestconfport')
219 @mock.patch('os.path.isfile', return_value=True)
220 def test_set_vars_ko(self, *args):
221 with mock.patch.object(self.test, 'set_robotframework_vars',
222 return_value=False) as mock_object:
223 self._test_run_suites(testcase.TestCase.EX_RUN_ERROR)
224 mock_object.assert_called_once_with(
225 self._odl_username, self._odl_password)
226 args[0].assert_called_once_with(self.test.odl_variables_file)
228 @mock.patch('os.makedirs')
229 @mock.patch('robot.run', side_effect=RobotError)
230 @mock.patch('os.path.isfile', return_value=True)
231 def test_run_ko(self, *args):
232 with mock.patch.object(self.test, 'set_robotframework_vars',
233 return_value=True), \
234 self.assertRaises(RobotError):
235 self._test_run_suites(testcase.TestCase.EX_RUN_ERROR, *args)
237 @mock.patch('os.makedirs')
238 @mock.patch('robot.run')
239 @mock.patch('os.path.isfile', return_value=True)
240 def test_parse_results_ko(self, *args):
241 with mock.patch.object(self.test, 'set_robotframework_vars',
242 return_value=True), \
243 mock.patch.object(self.test, 'parse_results',
244 side_effect=RobotError):
245 self._test_run_suites(testcase.TestCase.EX_RUN_ERROR, *args)
247 @mock.patch('os.makedirs')
248 @mock.patch('robot.run')
249 @mock.patch('os.path.isfile', return_value=True)
250 def test_ok(self, *args):
251 with mock.patch.object(self.test, 'set_robotframework_vars',
252 return_value=True), \
253 mock.patch.object(self.test, 'parse_results'):
254 self._test_run_suites(testcase.TestCase.EX_OK, *args)
256 @mock.patch('os.makedirs')
257 @mock.patch('robot.run')
258 @mock.patch('os.path.isfile', return_value=False)
259 def test_ok_no_creds(self, *args):
260 with mock.patch.object(self.test, 'set_robotframework_vars',
261 return_value=True) as mock_method, \
262 mock.patch.object(self.test, 'parse_results'):
263 self._test_run_suites(testcase.TestCase.EX_OK, *args)
264 mock_method.assert_not_called()
266 @mock.patch('os.makedirs')
267 @mock.patch('robot.run', return_value=1)
268 @mock.patch('os.path.isfile', return_value=True)
269 def test_testcases_in_failure(self, *args):
270 with mock.patch.object(self.test, 'set_robotframework_vars',
271 return_value=True), \
272 mock.patch.object(self.test, 'parse_results'):
273 self._test_run_suites(testcase.TestCase.EX_OK, *args)
276 class ODLRunTesting(ODLTesting):
277 """The class testing ODLTests.run()."""
278 # pylint: disable=too-many-public-methods,missing-docstring
280 @mock.patch('os_client_config.make_shade', side_effect=Exception)
281 def test_no_cloud(self, *args):
282 self.assertEqual(self.test.run(), testcase.TestCase.EX_RUN_ERROR)
283 args[0].assert_called_once_with()
285 @mock.patch('os_client_config.make_shade')
286 def test_no_service1(self, *args):
287 args[0].return_value.search_services.return_value = None
288 self.assertEqual(self.test.run(), testcase.TestCase.EX_RUN_ERROR)
289 args[0].return_value.search_services.assert_called_once_with('neutron')
290 args[0].return_value.search_endpoints.assert_not_called()
292 @mock.patch('os_client_config.make_shade')
293 def test_no_service2(self, *args):
294 args[0].return_value.search_services.return_value = []
295 self.assertEqual(self.test.run(), testcase.TestCase.EX_RUN_ERROR)
296 args[0].return_value.search_services.assert_called_once_with('neutron')
297 args[0].return_value.search_endpoints.assert_not_called()
299 @mock.patch('os_client_config.make_shade')
300 def test_no_service3(self, *args):
301 args[0].return_value.search_services.return_value = [
303 self.assertEqual(self.test.run(), testcase.TestCase.EX_RUN_ERROR)
304 args[0].return_value.search_services.assert_called_once_with('neutron')
305 args[0].return_value.search_endpoints.assert_not_called()
307 @mock.patch('os_client_config.make_shade')
308 def test_no_endpoint1(self, *args):
309 args[0].return_value.search_services.return_value = [
310 munch.Munch(id=self._neutron_id)]
311 args[0].return_value.search_endpoints.return_value = None
312 self.assertEqual(self.test.run(), testcase.TestCase.EX_RUN_ERROR)
313 args[0].return_value.search_services.assert_called_once_with('neutron')
314 args[0].return_value.search_endpoints.assert_called_once_with(
315 filters={'interface': self._os_interface,
316 'service_id': self._neutron_id})
318 @mock.patch('os_client_config.make_shade')
319 def test_no_endpoint2(self, *args):
320 args[0].return_value.search_services.return_value = [
321 munch.Munch(id=self._neutron_id)]
322 args[0].return_value.search_endpoints.return_value = []
323 self.assertEqual(self.test.run(), testcase.TestCase.EX_RUN_ERROR)
324 args[0].return_value.search_services.assert_called_once_with('neutron')
325 args[0].return_value.search_endpoints.assert_called_once_with(
326 filters={'interface': self._os_interface,
327 'service_id': self._neutron_id})
329 @mock.patch('os_client_config.make_shade')
330 def test_no_endpoint3(self, *args):
331 args[0].return_value.search_services.return_value = [
332 munch.Munch(id=self._neutron_id)]
333 args[0].return_value.search_endpoints.return_value = [munch.Munch()]
334 self.assertEqual(self.test.run(), testcase.TestCase.EX_RUN_ERROR)
335 args[0].return_value.search_services.assert_called_once_with('neutron')
336 args[0].return_value.search_endpoints.assert_called_once_with(
337 filters={'interface': self._os_interface,
338 'service_id': self._neutron_id})
340 @mock.patch('os_client_config.make_shade')
341 def test_endpoint_interface(self, *args):
342 args[0].return_value.search_services.return_value = [
343 munch.Munch(id=self._neutron_id)]
344 args[0].return_value.search_endpoints.return_value = [munch.Munch()]
345 self.assertEqual(self.test.run(), testcase.TestCase.EX_RUN_ERROR)
346 args[0].return_value.search_services.assert_called_once_with('neutron')
347 args[0].return_value.search_endpoints.assert_called_once_with(
348 filters={'interface': self._os_interface,
349 'service_id': self._neutron_id})
351 @mock.patch('os_client_config.make_shade')
352 def _test_no_env_var(self, var, *args):
354 self.assertEqual(self.test.run(), testcase.TestCase.EX_RUN_ERROR)
355 args[0].assert_called_once_with()
357 @mock.patch('os_client_config.make_shade')
358 def _test_missing_value(self, *args):
359 self.assertEqual(self.test.run(), testcase.TestCase.EX_RUN_ERROR)
360 args[0].assert_called_once_with()
362 @mock.patch('os_client_config.make_shade')
363 def _test_run(self, status=testcase.TestCase.EX_OK,
364 exception=None, *args, **kwargs):
365 args[0].return_value.search_services.return_value = [
366 munch.Munch(id=self._neutron_id)]
367 args[0].return_value.search_endpoints.return_value = [
368 munch.Munch(url=self._neutron_url)]
369 odlip = kwargs['odlip'] if 'odlip' in kwargs else '127.0.0.3'
370 odlwebport = kwargs['odlwebport'] if 'odlwebport' in kwargs else '8080'
371 odlrestconfport = (kwargs['odlrestconfport']
372 if 'odlrestconfport' in kwargs else '8181')
374 self.test.run_suites = mock.Mock(side_effect=exception)
376 self.test.run_suites = mock.Mock(return_value=status)
377 self.assertEqual(self.test.run(), status)
378 self.test.run_suites.assert_called_once_with(
379 odl.ODLTests.default_suites, neutronurl=self._neutron_url,
380 odlip=odlip, odlpassword=self._odl_password,
381 odlrestconfport=odlrestconfport, odlusername=self._odl_username,
382 odlwebport=odlwebport, osauthurl=self._os_auth_url,
383 ospassword=self._os_password, osprojectname=self._os_projectname,
384 osusername=self._os_username,
385 osprojectdomainname=self._os_projectdomainname,
386 osuserdomainname=self._os_userdomainname)
387 args[0].assert_called_once_with()
388 args[0].return_value.search_services.assert_called_once_with('neutron')
389 args[0].return_value.search_endpoints.assert_called_once_with(
390 filters={'interface': os.environ.get("OS_INTERFACE", "public"),
391 'service_id': self._neutron_id})
393 @mock.patch('os_client_config.make_shade')
394 def _test_multiple_suites(self, suites,
395 status=testcase.TestCase.EX_OK, *args, **kwargs):
396 args[0].return_value.search_endpoints.return_value = [
397 munch.Munch(url=self._neutron_url)]
398 args[0].return_value.search_services.return_value = [
399 munch.Munch(id=self._neutron_id)]
400 odlip = kwargs['odlip'] if 'odlip' in kwargs else '127.0.0.3'
401 odlwebport = kwargs['odlwebport'] if 'odlwebport' in kwargs else '8080'
402 odlrestconfport = (kwargs['odlrestconfport']
403 if 'odlrestconfport' in kwargs else '8181')
404 self.test.run_suites = mock.Mock(return_value=status)
405 self.assertEqual(self.test.run(suites=suites), status)
406 self.test.run_suites.assert_called_once_with(
407 suites, neutronurl=self._neutron_url, odlip=odlip,
408 odlpassword=self._odl_password, odlrestconfport=odlrestconfport,
409 odlusername=self._odl_username, odlwebport=odlwebport,
410 osauthurl=self._os_auth_url, ospassword=self._os_password,
411 osprojectname=self._os_projectname, osusername=self._os_username,
412 osprojectdomainname=self._os_projectdomainname,
413 osuserdomainname=self._os_userdomainname)
414 args[0].assert_called_once_with()
415 args[0].return_value.search_services.assert_called_once_with('neutron')
416 args[0].return_value.search_endpoints.assert_called_once_with(
417 filters={'interface': os.environ.get("OS_INTERFACE", "public"),
418 'service_id': self._neutron_id})
421 with mock.patch('os_client_config.make_shade',
422 side_effect=Exception()):
423 self.assertEqual(self.test.run(),
424 testcase.TestCase.EX_RUN_ERROR)
426 def test_no_os_auth_url(self):
427 self._test_no_env_var("OS_AUTH_URL")
429 def test_no_os_username(self):
430 self._test_no_env_var("OS_USERNAME")
432 def test_no_os_password(self):
433 self._test_no_env_var("OS_PASSWORD")
435 def test_no_os__name(self):
436 self._test_no_env_var("OS_PROJECT_NAME")
438 def test_run_suites_false(self):
439 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
440 self._test_run(testcase.TestCase.EX_RUN_ERROR, None,
441 odlip=self._sdn_controller_ip,
442 odlwebport=self._odl_webport)
444 def test_run_suites_exc(self):
445 with self.assertRaises(Exception):
446 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
447 self._test_run(testcase.TestCase.EX_RUN_ERROR,
449 odlip=self._sdn_controller_ip,
450 odlwebport=self._odl_webport)
452 def test_no_sdn_controller_ip(self):
453 self._test_missing_value()
455 def test_without_installer_type(self):
456 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
457 self._test_run(testcase.TestCase.EX_OK, None,
458 odlip=self._sdn_controller_ip,
459 odlwebport=self._odl_webport)
461 def test_without_os_interface(self):
462 del os.environ["OS_INTERFACE"]
463 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
464 self._test_run(testcase.TestCase.EX_OK, None,
465 odlip=self._sdn_controller_ip,
466 odlwebport=self._odl_webport)
468 def test_os_interface_public(self):
469 os.environ["OS_INTERFACE"] = "public"
470 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
471 self._test_run(testcase.TestCase.EX_OK, None,
472 odlip=self._sdn_controller_ip,
473 odlwebport=self._odl_webport)
475 def test_os_interface_internal(self):
476 os.environ["OS_INTERFACE"] = "internal"
477 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
478 self._test_run(testcase.TestCase.EX_OK, None,
479 odlip=self._sdn_controller_ip,
480 odlwebport=self._odl_webport)
482 def test_os_interface_admin(self):
483 os.environ["OS_INTERFACE"] = "admin"
484 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
485 self._test_run(testcase.TestCase.EX_OK, None,
486 odlip=self._sdn_controller_ip,
487 odlwebport=self._odl_webport)
489 def test_suites(self):
490 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
491 self._test_multiple_suites(
492 [odl.ODLTests.basic_suite_dir],
493 testcase.TestCase.EX_OK,
494 odlip=self._sdn_controller_ip,
495 odlwebport=self._odl_webport)
497 def test_fuel_no_controller_ip(self):
498 os.environ["INSTALLER_TYPE"] = "fuel"
499 self._test_missing_value()
502 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
503 os.environ["INSTALLER_TYPE"] = "fuel"
504 self._test_run(testcase.TestCase.EX_OK, None,
505 odlip=self._sdn_controller_ip,
507 odlrestconfport='8282')
509 def test_apex_no_controller_ip(self):
510 os.environ["INSTALLER_TYPE"] = "apex"
511 self._test_missing_value()
514 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
515 os.environ["INSTALLER_TYPE"] = "apex"
516 self._test_run(testcase.TestCase.EX_OK, None,
517 odlip=self._sdn_controller_ip, odlwebport='8081',
518 odlrestconfport='8081')
520 def test_netvirt_no_controller_ip(self):
521 os.environ["INSTALLER_TYPE"] = "netvirt"
522 self._test_missing_value()
524 def test_netvirt(self):
525 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
526 os.environ["INSTALLER_TYPE"] = "netvirt"
527 self._test_run(testcase.TestCase.EX_OK, None,
528 odlip=self._sdn_controller_ip, odlwebport='8081',
529 odlrestconfport='8081')
531 def test_compass(self):
532 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
533 os.environ["INSTALLER_TYPE"] = "compass"
534 self._test_run(testcase.TestCase.EX_OK, None,
535 odlip=self._sdn_controller_ip,
536 odlrestconfport='8080')
538 def test_daisy_no_controller_ip(self):
539 os.environ["INSTALLER_TYPE"] = "daisy"
540 self._test_missing_value()
542 def test_daisy(self):
543 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
544 os.environ["INSTALLER_TYPE"] = "daisy"
545 self._test_run(testcase.TestCase.EX_OK, None,
546 odlip=self._sdn_controller_ip, odlwebport='8181',
547 odlrestconfport='8087')
550 class ODLArgParserTesting(ODLTesting):
552 """The class testing ODLParser."""
553 # pylint: disable=missing-docstring
556 self.parser = odl.ODLParser()
557 super(ODLArgParserTesting, self).setUp()
559 def test_default(self):
560 self.assertEqual(self.parser.parse_args(), self.defaultargs)
562 def test_basic(self):
563 self.defaultargs['neutronurl'] = self._neutron_url
564 self.defaultargs['odlip'] = self._sdn_controller_ip
566 self.parser.parse_args(
567 ["--neutronurl={}".format(self._neutron_url),
568 "--odlip={}".format(self._sdn_controller_ip)]),
571 @mock.patch('sys.stderr', new_callable=six.StringIO)
572 def test_fail(self, mock_method):
573 self.defaultargs['foo'] = 'bar'
574 with self.assertRaises(SystemExit):
575 self.parser.parse_args(["--foo=bar"])
576 self.assertTrue(mock_method.getvalue().startswith("usage:"))
578 def _test_arg(self, arg, value):
579 self.defaultargs[arg] = value
581 self.parser.parse_args(["--{}={}".format(arg, value)]),
584 def test_odlusername(self):
585 self._test_arg('odlusername', 'foo')
587 def test_odlpassword(self):
588 self._test_arg('odlpassword', 'foo')
590 def test_osauthurl(self):
591 self._test_arg('osauthurl', 'http://127.0.0.4:5000/v2')
593 def test_neutronurl(self):
594 self._test_arg('neutronurl', 'http://127.0.0.4:9696')
596 def test_osusername(self):
597 self._test_arg('osusername', 'foo')
599 def test_osuserdomainname(self):
600 self._test_arg('osuserdomainname', 'domain')
602 def test_osprojectname(self):
603 self._test_arg('osprojectname', 'foo')
605 def test_osprojectdomainname(self):
606 self._test_arg('osprojectdomainname', 'domain')
608 def test_ospassword(self):
609 self._test_arg('ospassword', 'foo')
611 def test_odlip(self):
612 self._test_arg('odlip', '127.0.0.4')
614 def test_odlwebport(self):
615 self._test_arg('odlwebport', '80')
617 def test_odlrestconfport(self):
618 self._test_arg('odlrestconfport', '80')
620 def test_pushtodb(self):
621 self.defaultargs['pushtodb'] = True
622 self.assertEqual(self.parser.parse_args(["--{}".format('pushtodb')]),
625 def test_multiple_args(self):
626 self.defaultargs['neutronurl'] = self._neutron_url
627 self.defaultargs['odlip'] = self._sdn_controller_ip
629 self.parser.parse_args(
630 ["--neutronurl={}".format(self._neutron_url),
631 "--odlip={}".format(self._sdn_controller_ip)]),
635 if __name__ == "__main__":
636 logging.disable(logging.CRITICAL)
637 unittest.main(verbosity=2)