diff options
author | Liang Ke <lokyse@163.com> | 2018-03-26 04:11:36 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-03-26 04:11:36 +0000 |
commit | 232d67e942a2ea7334a6835737bab50c355e978f (patch) | |
tree | 89a9d9f4bc3a0953193bdfaff583c1438485e69b /multivimbroker | |
parent | 65a6aa1e184dd4081cf67d3009c26302b16e5c17 (diff) | |
parent | a88f4070e869f1f7d9733275d1d142bd0ca2bf93 (diff) |
Merge "Add test_getMultivimDriver"
Diffstat (limited to 'multivimbroker')
-rw-r--r-- | multivimbroker/multivimbroker/pub/utils/syscomm.py | 4 | ||||
-rw-r--r-- | multivimbroker/multivimbroker/tests/test_syscomm.py | 13 |
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) |