1 # Copyright (c) 2017-2018 VMware, Inc.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 from multivimbroker.pub import exceptions
15 from multivimbroker.pub.msapi import extsys
16 from multivimbroker.pub.utils import syscomm
19 class TestSyscomm(unittest.TestCase):
21 def test_getVIMTypes(self):
23 "openstack": ["titanium_cloud", "ocata"],
26 ret = syscomm.getVIMTypes()
28 for v in item['versions']:
29 self.assertIn(v, expected_body[item['vim_type']])
31 @mock.patch.object(extsys, "get_vim_by_id")
32 def test_getMultivimDriver(self, mock_get_vim):
33 mock_get_vim.return_value = {
37 full_path = "multicloud/v0/openstack_regionone/identity"
38 expect_path = "multicloud-ocata/v0/openstack_regionone/identity"
39 ret_path = syscomm.getMultivimDriver("openstack_regionone", full_path)
40 self.assertEqual(expect_path, ret_path)
42 def test_findMultivimDriver_no_type(self):
43 vim = {"type": "wrong type"}
44 self.assertRaises(exceptions.NotFound, syscomm.findMultivimDriver, vim)
46 def test_findMultivimDriver_no_version(self):
47 vim = {"type": "openstack"}
48 ret = syscomm.findMultivimDriver(vim)
49 self.assertEqual("multicloud-ocata", ret)
51 def test_findMultivimDriver_with_version(self):
52 vim = {"type": "openstack", "version": "titanium_cloud"}
53 ret = syscomm.findMultivimDriver(vim)
54 self.assertEqual("multicloud-titanium_cloud", ret)