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.msapi import extsys
15 from multivimbroker.pub.utils import restcall
18 class TestExtsys(unittest.TestCase):
20 def test_split_vim_to_owner_region(self):
21 vim_id = "openstack_regionone"
22 cloud_owner, cloud_region = extsys.split_vim_to_owner_region(vim_id)
23 self.assertEqual("openstack", cloud_owner)
24 self.assertEqual("regionone", cloud_region)
26 @mock.patch.object(restcall, "get_res_from_aai")
27 def test_get_vim_by_id_success(self, mock_get_res):
29 "cloud-type": "openstack",
30 "cloud-region-version": "regionone"
32 mock_get_res.return_value = (0, resp_body, 200, mock.Mock())
33 vim_id = "openstack_regionone"
34 ret = extsys.get_vim_by_id(vim_id)
36 "cloud-type": "openstack",
37 "cloud-region-version": "regionone",
39 "version": "regionone",
42 self.assertDictEqual(expect_ret, ret)