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 # pylint: disable=keyword-arg-before-vararg
366 args[0].return_value.search_services.return_value = [
367 munch.Munch(id=self._neutron_id)]
368 args[0].return_value.search_endpoints.return_value = [
369 munch.Munch(url=self._neutron_url)]
370 odlip = kwargs['odlip'] if 'odlip' in kwargs else '127.0.0.3'
371 odlwebport = kwargs['odlwebport'] if 'odlwebport' in kwargs else '8080'
372 odlrestconfport = (kwargs['odlrestconfport']
373 if 'odlrestconfport' in kwargs else '8181')
375 self.test.run_suites = mock.Mock(side_effect=exception)
377 self.test.run_suites = mock.Mock(return_value=status)
378 self.assertEqual(self.test.run(), status)
379 self.test.run_suites.assert_called_once_with(
380 odl.ODLTests.default_suites, neutronurl=self._neutron_url,
381 odlip=odlip, odlpassword=self._odl_password,
382 odlrestconfport=odlrestconfport, odlusername=self._odl_username,
383 odlwebport=odlwebport, osauthurl=self._os_auth_url,
384 ospassword=self._os_password, osprojectname=self._os_projectname,
385 osusername=self._os_username,
386 osprojectdomainname=self._os_projectdomainname,
387 osuserdomainname=self._os_userdomainname)
388 args[0].assert_called_once_with()
389 args[0].return_value.search_services.assert_called_once_with('neutron')
390 args[0].return_value.search_endpoints.assert_called_once_with(
391 filters={'interface': os.environ.get("OS_INTERFACE", "public"),
392 'service_id': self._neutron_id})
394 @mock.patch('os_client_config.make_shade')
395 def _test_multiple_suites(self, suites,
396 status=testcase.TestCase.EX_OK, *args, **kwargs):
397 # pylint: disable=keyword-arg-before-vararg
398 args[0].return_value.search_endpoints.return_value = [
399 munch.Munch(url=self._neutron_url)]
400 args[0].return_value.search_services.return_value = [
401 munch.Munch(id=self._neutron_id)]
402 odlip = kwargs['odlip'] if 'odlip' in kwargs else '127.0.0.3'
403 odlwebport = kwargs['odlwebport'] if 'odlwebport' in kwargs else '8080'
404 odlrestconfport = (kwargs['odlrestconfport']
405 if 'odlrestconfport' in kwargs else '8181')
406 self.test.run_suites = mock.Mock(return_value=status)
407 self.assertEqual(self.test.run(suites=suites), status)
408 self.test.run_suites.assert_called_once_with(
409 suites, neutronurl=self._neutron_url, odlip=odlip,
410 odlpassword=self._odl_password, odlrestconfport=odlrestconfport,
411 odlusername=self._odl_username, odlwebport=odlwebport,
412 osauthurl=self._os_auth_url, ospassword=self._os_password,
413 osprojectname=self._os_projectname, osusername=self._os_username,
414 osprojectdomainname=self._os_projectdomainname,
415 osuserdomainname=self._os_userdomainname)
416 args[0].assert_called_once_with()
417 args[0].return_value.search_services.assert_called_once_with('neutron')
418 args[0].return_value.search_endpoints.assert_called_once_with(
419 filters={'interface': os.environ.get("OS_INTERFACE", "public"),
420 'service_id': self._neutron_id})
423 with mock.patch('os_client_config.make_shade',
424 side_effect=Exception()):
425 self.assertEqual(self.test.run(),
426 testcase.TestCase.EX_RUN_ERROR)
428 def test_no_os_auth_url(self):
429 self._test_no_env_var("OS_AUTH_URL")
431 def test_no_os_username(self):
432 self._test_no_env_var("OS_USERNAME")
434 def test_no_os_password(self):
435 self._test_no_env_var("OS_PASSWORD")
437 def test_no_os__name(self):
438 self._test_no_env_var("OS_PROJECT_NAME")
440 def test_run_suites_false(self):
441 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
442 self._test_run(testcase.TestCase.EX_RUN_ERROR, None,
443 odlip=self._sdn_controller_ip,
444 odlwebport=self._odl_webport)
446 def test_run_suites_exc(self):
447 with self.assertRaises(Exception):
448 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
449 self._test_run(testcase.TestCase.EX_RUN_ERROR,
451 odlip=self._sdn_controller_ip,
452 odlwebport=self._odl_webport)
454 def test_no_sdn_controller_ip(self):
455 self._test_missing_value()
457 def test_without_installer_type(self):
458 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
459 self._test_run(testcase.TestCase.EX_OK, None,
460 odlip=self._sdn_controller_ip,
461 odlwebport=self._odl_webport)
463 def test_without_os_interface(self):
464 del os.environ["OS_INTERFACE"]
465 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
466 self._test_run(testcase.TestCase.EX_OK, None,
467 odlip=self._sdn_controller_ip,
468 odlwebport=self._odl_webport)
470 def test_os_interface_public(self):
471 os.environ["OS_INTERFACE"] = "public"
472 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
473 self._test_run(testcase.TestCase.EX_OK, None,
474 odlip=self._sdn_controller_ip,
475 odlwebport=self._odl_webport)
477 def test_os_interface_internal(self):
478 os.environ["OS_INTERFACE"] = "internal"
479 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
480 self._test_run(testcase.TestCase.EX_OK, None,
481 odlip=self._sdn_controller_ip,
482 odlwebport=self._odl_webport)
484 def test_os_interface_admin(self):
485 os.environ["OS_INTERFACE"] = "admin"
486 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
487 self._test_run(testcase.TestCase.EX_OK, None,
488 odlip=self._sdn_controller_ip,
489 odlwebport=self._odl_webport)
491 def test_suites(self):
492 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
493 self._test_multiple_suites(
494 [odl.ODLTests.basic_suite_dir],
495 testcase.TestCase.EX_OK,
496 odlip=self._sdn_controller_ip,
497 odlwebport=self._odl_webport)
499 def test_fuel_no_controller_ip(self):
500 os.environ["INSTALLER_TYPE"] = "fuel"
501 self._test_missing_value()
504 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
505 os.environ["INSTALLER_TYPE"] = "fuel"
506 self._test_run(testcase.TestCase.EX_OK, None,
507 odlip=self._sdn_controller_ip,
509 odlrestconfport='8282')
511 def test_apex_no_controller_ip(self):
512 os.environ["INSTALLER_TYPE"] = "apex"
513 self._test_missing_value()
516 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
517 os.environ["INSTALLER_TYPE"] = "apex"
518 self._test_run(testcase.TestCase.EX_OK, None,
519 odlip=self._sdn_controller_ip, odlwebport='8081',
520 odlrestconfport='8081')
522 def test_netvirt_no_controller_ip(self):
523 os.environ["INSTALLER_TYPE"] = "netvirt"
524 self._test_missing_value()
526 def test_netvirt(self):
527 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
528 os.environ["INSTALLER_TYPE"] = "netvirt"
529 self._test_run(testcase.TestCase.EX_OK, None,
530 odlip=self._sdn_controller_ip, odlwebport='8081',
531 odlrestconfport='8081')
533 def test_compass(self):
534 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
535 os.environ["INSTALLER_TYPE"] = "compass"
536 self._test_run(testcase.TestCase.EX_OK, None,
537 odlip=self._sdn_controller_ip,
538 odlrestconfport='8080')
540 def test_daisy_no_controller_ip(self):
541 os.environ["INSTALLER_TYPE"] = "daisy"
542 self._test_missing_value()
544 def test_daisy(self):
545 os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
546 os.environ["INSTALLER_TYPE"] = "daisy"
547 self._test_run(testcase.TestCase.EX_OK, None,
548 odlip=self._sdn_controller_ip, odlwebport='8181',
549 odlrestconfport='8087')
552 class ODLArgParserTesting(ODLTesting):
554 """The class testing ODLParser."""
555 # pylint: disable=missing-docstring
558 self.parser = odl.ODLParser()
559 super(ODLArgParserTesting, self).setUp()
561 def test_default(self):
562 self.assertEqual(self.parser.parse_args(), self.defaultargs)
564 def test_basic(self):
565 self.defaultargs['neutronurl'] = self._neutron_url
566 self.defaultargs['odlip'] = self._sdn_controller_ip
568 self.parser.parse_args(
569 ["--neutronurl={}".format(self._neutron_url),
570 "--odlip={}".format(self._sdn_controller_ip)]),
573 @mock.patch('sys.stderr', new_callable=six.StringIO)
574 def test_fail(self, mock_method):
575 self.defaultargs['foo'] = 'bar'
576 with self.assertRaises(SystemExit):
577 self.parser.parse_args(["--foo=bar"])
578 self.assertTrue(mock_method.getvalue().startswith("usage:"))
580 def _test_arg(self, arg, value):
581 self.defaultargs[arg] = value
583 self.parser.parse_args(["--{}={}".format(arg, value)]),
586 def test_odlusername(self):
587 self._test_arg('odlusername', 'foo')
589 def test_odlpassword(self):
590 self._test_arg('odlpassword', 'foo')
592 def test_osauthurl(self):
593 self._test_arg('osauthurl', 'http://127.0.0.4:5000/v2')
595 def test_neutronurl(self):
596 self._test_arg('neutronurl', 'http://127.0.0.4:9696')
598 def test_osusername(self):
599 self._test_arg('osusername', 'foo')
601 def test_osuserdomainname(self):
602 self._test_arg('osuserdomainname', 'domain')
604 def test_osprojectname(self):
605 self._test_arg('osprojectname', 'foo')
607 def test_osprojectdomainname(self):
608 self._test_arg('osprojectdomainname', 'domain')
610 def test_ospassword(self):
611 self._test_arg('ospassword', 'foo')
613 def test_odlip(self):
614 self._test_arg('odlip', '127.0.0.4')
616 def test_odlwebport(self):
617 self._test_arg('odlwebport', '80')
619 def test_odlrestconfport(self):
620 self._test_arg('odlrestconfport', '80')
622 def test_pushtodb(self):
623 self.defaultargs['pushtodb'] = True
624 self.assertEqual(self.parser.parse_args(["--{}".format('pushtodb')]),
627 def test_multiple_args(self):
628 self.defaultargs['neutronurl'] = self._neutron_url
629 self.defaultargs['odlip'] = self._sdn_controller_ip
631 self.parser.parse_args(
632 ["--neutronurl={}".format(self._neutron_url),
633 "--odlip={}".format(self._sdn_controller_ip)]),
637 if __name__ == "__main__":
638 logging.disable(logging.CRITICAL)
639 unittest.main(verbosity=2)