summaryrefslogtreecommitdiffstats
path: root/multivimbroker
diff options
context:
space:
mode:
authorEthan Lynn <ethanlynnl@vmware.com>2018-03-25 19:40:20 -0700
committerEthan Lynn <ethanlynnl@vmware.com>2018-03-25 19:41:29 -0700
commita88f4070e869f1f7d9733275d1d142bd0ca2bf93 (patch)
tree7f174d544ef84ee204625728b6d4b9955b549c95 /multivimbroker
parent02d164d5aea5bf6a8d3077f05217328a6f12a6ef (diff)
Add test_getMultivimDriver
Add test_getMultivimDriver for syscomm.py Change-Id: I5e9c38aa18f6c857e59ddc3570e74f0239d94f61 Issue-ID: MULTICLOUD-198 Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
Diffstat (limited to 'multivimbroker')
-rw-r--r--multivimbroker/multivimbroker/pub/utils/syscomm.py4
-rw-r--r--multivimbroker/multivimbroker/tests/test_syscomm.py13
2 files changed, 15 insertions, 2 deletions
diff --git a/multivimbroker/multivimbroker/pub/utils/syscomm.py b/multivimbroker/multivimbroker/pub/utils/syscomm.py
index 337a1bd..7a45395 100644
--- a/multivimbroker/multivimbroker/pub/utils/syscomm.py
+++ b/multivimbroker/multivimbroker/pub/utils/syscomm.py
@@ -16,7 +16,7 @@ import os
import re
import multivimbroker.pub.exceptions as exceptions
-from multivimbroker.pub.msapi.extsys import get_vim_by_id
+from multivimbroker.pub.msapi import extsys
def fun_name():
@@ -59,7 +59,7 @@ def findMultivimDriver(vim=None):
def getMultivimDriver(vimid, full_path=""):
multcloud = "multicloud"
- vim = get_vim_by_id(vimid)
+ vim = extsys.get_vim_by_id(vimid)
multclouddriver = findMultivimDriver(vim=vim)
return re.sub(multcloud, multclouddriver, full_path)
diff --git a/multivimbroker/multivimbroker/tests/test_syscomm.py b/multivimbroker/multivimbroker/tests/test_syscomm.py
index bed857d..ac43877 100644
--- a/multivimbroker/multivimbroker/tests/test_syscomm.py
+++ b/multivimbroker/multivimbroker/tests/test_syscomm.py
@@ -8,8 +8,10 @@
# 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 multivimbroker.pub.msapi import extsys
from multivimbroker.pub.utils import syscomm
@@ -24,3 +26,14 @@ class TestSyscomm(unittest.TestCase):
for item in ret:
for v in item['versions']:
self.assertIn(v, expected_body[item['vim_type']])
+
+ @mock.patch.object(extsys, "get_vim_by_id")
+ def test_getMultivimDriver(self, mock_get_vim):
+ mock_get_vim.return_value = {
+ "type": "openstack",
+ "version": "ocata"
+ }
+ full_path = "multicloud/v0/openstack_regionone/identity"
+ expect_path = "multicloud-ocata/v0/openstack_regionone/identity"
+ ret_path = syscomm.getMultivimDriver("openstack_regionone", full_path)
+ self.assertEqual(expect_path, ret_path)