summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Ke <lokyse@163.com>2018-07-04 03:06:53 +0000
committerGerrit Code Review <gerrit@onap.org>2018-07-04 03:06:53 +0000
commitcbed455e93e1e24a002171cef44d82c197e86353 (patch)
tree89dec53b6da2a3eefdcd57216bbfd459eed3a3a3
parent6184c62c07824236deec259360d8634e8e6b7d35 (diff)
parent8bde08e4be9a0183fb720d6a2b692343597eefcf (diff)
Merge changes from topic 'ut2'
* changes: Add test_convert_default_val Add test_get_vim_session_v3 Add test_get_vim_session_v2
-rw-r--r--vio/vio/tests/test_apiv2_controller.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/vio/vio/tests/test_apiv2_controller.py b/vio/vio/tests/test_apiv2_controller.py
new file mode 100644
index 0000000..132a105
--- /dev/null
+++ b/vio/vio/tests/test_apiv2_controller.py
@@ -0,0 +1,52 @@
+# Copyright (c) 2018 VMware, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+import mock
+import unittest
+
+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.pub.msapi import extsys
+
+
+class TestAPIv2Controller(unittest.TestCase):
+
+ @mock.patch.object(keystone_v2, "Password")
+ @mock.patch.object(extsys, "get_vim_by_id")
+ def test_get_vim_session_v2(self, mock_getvim, mock_kv2):
+ mock_getvim.return_value = {
+ "url": "http://aa/v2",
+ "userName": "admin",
+ "password": "admin",
+ "domain": "default"
+ }
+ mock_kv2.return_value = mock.Mock()
+ cb._get_vim_auth_session("vmware_vio", "tenant1")
+
+ @mock.patch.object(keystone_v3, "Password")
+ @mock.patch.object(extsys, "get_vim_by_id")
+ def test_get_vim_session_v3(self, mock_getvim, mock_kv3):
+ mock_getvim.return_value = {
+ "url": "http://aa/v3",
+ "userName": "admin",
+ "password": "admin",
+ "domain": "default"
+ }
+ mock_kv3.return_value = mock.Mock()
+ cb._get_vim_auth_session("vmware_vio", "tenant1")
+
+ def test_convert_default_val(self):
+ self.assertEqual(None, cb._convert_default_value("None"))
+ self.assertEqual(True, cb._convert_default_value("true"))
+ self.assertEqual(False, cb._convert_default_value("false"))