Add test_getMultivimDriver 37/38337/1
authorEthan Lynn <ethanlynnl@vmware.com>
Mon, 26 Mar 2018 02:40:20 +0000 (19:40 -0700)
committerEthan Lynn <ethanlynnl@vmware.com>
Mon, 26 Mar 2018 02:41:29 +0000 (19:41 -0700)
Add test_getMultivimDriver for syscomm.py

Change-Id: I5e9c38aa18f6c857e59ddc3570e74f0239d94f61
Issue-ID: MULTICLOUD-198
Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
multivimbroker/multivimbroker/pub/utils/syscomm.py
multivimbroker/multivimbroker/tests/test_syscomm.py

index 337a1bd..7a45395 100644 (file)
@@ -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)
 
index bed857d..ac43877 100644 (file)
@@ -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)