summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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)