diff options
author | Liang Ke <lokyse@163.com> | 2018-07-04 03:08:27 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-07-04 03:08:27 +0000 |
commit | 8d59d11e80d68103177ba77c251b02ecf9de9543 (patch) | |
tree | 35428a930075c896998430f7d5ffbd7b6e902541 | |
parent | 24c60ce631ee75010d8a58fd1eb0493040839ed9 (diff) | |
parent | a52cde8ff99196daa62963fe677fe3e1bc91d6bb (diff) |
Merge changes from topic 'ut2'
* changes:
Add test_insert_dynamic_controller
Add test_property_exist
-rw-r--r-- | vio/vio/tests/test_apiv2_controller.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/vio/vio/tests/test_apiv2_controller.py b/vio/vio/tests/test_apiv2_controller.py index 132a105..d48b769 100644 --- a/vio/vio/tests/test_apiv2_controller.py +++ b/vio/vio/tests/test_apiv2_controller.py @@ -17,6 +17,7 @@ from keystoneauth1.identity import v2 as keystone_v2 from keystoneauth1.identity import v3 as keystone_v3 from vio.api_v2.api_router import controller_builder as cb +from vio.api_v2.api_router import v0_controller from vio.pub.msapi import extsys @@ -50,3 +51,21 @@ class TestAPIv2Controller(unittest.TestCase): self.assertEqual(None, cb._convert_default_value("None")) self.assertEqual(True, cb._convert_default_value("true")) self.assertEqual(False, cb._convert_default_value("false")) + + def test_property_exist(self): + res = { + "pp": "dd" + } + self.assertEqual(True, cb._property_exists(res, "pp", required=False)) + self.assertEqual(False, cb._property_exists(res, "dd", required=False)) + self.assertRaises( + Exception, cb._property_exists, res, "dd", required=True) + + def test_insert_dynamic_controller(self): + controller = v0_controller.V0_Controller() + cb.insert_dynamic_controller(controller) + self.assertEqual(True, hasattr(controller, "hosts")) + self.assertEqual(True, hasattr(controller, "images")) + self.assertEqual(True, hasattr(controller, "ports")) + self.assertEqual(True, hasattr(controller, "networks")) + self.assertEqual(True, hasattr(controller, "subnets")) |