Added V0 Registry API
[multicloud/azure.git] / azure / multicloud_azure / tests / test_aai_client.py
1 # Copyright (c) 2018 Amdocs
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
13 import mock
14 import unittest
15
16 from multicloud_azure.pub.utils import restcall
17
18
19 class TestAAIClient(unittest.TestCase):
20
21     def setUp(self):
22         self.view = restcall.AAIClient("vmware", "4.0")
23
24     @mock.patch.object(restcall, "call_req")
25     def test_get_vim(self, mock_call):
26         mock_call.return_value = [0, '{"cloudOwner": "vmware"}']
27         ret = self.view.get_vim(get_all=True)
28         expect_ret = {"cloudOwner": "vmware"}
29         self.assertEqual(expect_ret, ret)
30
31     @mock.patch.object(restcall.AAIClient, "get_vim")
32     @mock.patch.object(restcall, "call_req")
33     def test_update_identity_url(self, mock_call, mock_getvim):
34         mock_getvim.return_value = {}
35         self.view.update_identity_url()
36         mock_call.assert_called_once()
37
38     @mock.patch.object(restcall, "call_req")
39     def test_add_flavors(self, mock_call):
40         flavors = {
41             "flavors": [{
42                 "name": "m1.small",
43                 "id": "1",
44                 "vcpus": 1,
45                 "ram": 512,
46                 "disk": 10,
47                 "ephemeral": 0,
48                 "swap": 0,
49                 "is_public": True,
50                 "links": [{"href": "http://fake-url"}],
51                 "is_disabled": False
52             }]
53         }
54         self.view.add_flavors(flavors)
55         mock_call.assert_called_once()
56
57     @mock.patch.object(restcall, "call_req")
58     def test_add_flavors_with_hpa(self, mock_call):
59         flavors = {
60             "flavors": [{
61                 "name": "onap.small",
62                 "id": "1",
63                 "vcpus": 1,
64                 "ram": 512,
65                 "disk": 10,
66                 "ephemeral": 0,
67                 "swap": 0,
68                 "is_public": True,
69                 "links": [{"href": "http://fake-url"}],
70                 "is_disabled": False,
71                 "extra_specs": {},
72             }]
73         }
74         self.view._get_ovsdpdk_capabilities = mock.MagicMock()
75         self.view._get_ovsdpdk_capabilities.return_value = {}
76         self.view.add_flavors(flavors)
77         mock_call.assert_called_once()