summaryrefslogtreecommitdiffstats
path: root/windriver/titanium_cloud/registration/tests
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-07-04 14:57:58 +0800
committerYun Huang <yun.huang@windriver.com>2018-07-04 14:57:58 +0800
commit0c97e69480aa3113cbf0cd54ebd35998a3078089 (patch)
tree57424c9e0ebe2ba8cf7f288829f0c73525fb96dd /windriver/titanium_cloud/registration/tests
parent79ab438ee7ef74729dd793cb2640cf96349c63e1 (diff)
UT for registration flavors
Change-Id: I687bd65d59d928f97fa0a09fa889c01c5a6fe11f Issue-ID: MULTICLOUD-230 Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'windriver/titanium_cloud/registration/tests')
-rw-r--r--windriver/titanium_cloud/registration/tests/test_registration2.py97
1 files changed, 97 insertions, 0 deletions
diff --git a/windriver/titanium_cloud/registration/tests/test_registration2.py b/windriver/titanium_cloud/registration/tests/test_registration2.py
new file mode 100644
index 00000000..38cbabdb
--- /dev/null
+++ b/windriver/titanium_cloud/registration/tests/test_registration2.py
@@ -0,0 +1,97 @@
+# Copyright (c) 2017-2018 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import mock
+
+import unittest
+import json
+from django.test import Client
+from rest_framework import status
+
+from django.core.cache import cache
+from common.msapi import extsys
+
+from common.utils import restcall
+from newton_base.tests import mock_info
+from newton_base.tests import test_base
+from newton_base.util import VimDriverUtils
+
+from newton_base.registration import registration as newton_registration
+from titanium_cloud.registration.views import registration
+from newton_base.tests import test_base
+
+MOCK_VIM_INFO = {
+ "createTime": "2017-04-01 02:22:27",
+ "domain": "Default",
+ "name": "TiS_R4",
+ "password": "admin",
+ "tenant": "admin",
+ "type": "openstack",
+ "url": "http://128.224.180.14:5000/v3",
+ "userName": "admin",
+ "vendor": "WindRiver",
+ "version": "newton",
+ "vimId": "windriver-hudson-dc_RegionOne",
+ 'cloud_owner': 'windriver-hudson-dc',
+ 'cloud_region_id': 'RegionOne',
+ 'cloud_extra_info': '',
+ 'cloud_epa_caps':
+ '{'
+ '"huge_page":"true",'
+ '"cpu_pinning":"true",'
+ '"cpu_thread_policy":"true",'
+ '"numa_aware":"true",'
+ '"sriov":"true",'
+ '"dpdk_vswitch":"true",'
+ '"rdt":"false",'
+ '"numa_locality_pci":"true"'
+ '}',
+ 'insecure': 'True',
+}
+
+MOCK_GET_FLAVOR_RESPONSE = {
+ "flavors": [
+ {
+ "id": "1", "name": "micro", "vcpus": 1, "ram": "1MB",
+ "disk": "1G", "OS-FLV-EXT-DATA:ephemeral": False,
+ "swap": True, "os-flavor-access:is_public": True,
+ "OS-FLV-DISABLED:disabled": True, "link": [{"href":1}]
+ },
+ {
+ "id": "2", "name": "mini", "vcpus": 2, "ram": "2MB",
+ "disk": "2G", "OS-FLV-EXT-DATA:ephemeral": True,
+ "swap": False, "os-flavor-access:is_public": True,
+ "OS-FLV-DISABLED:disabled": True
+ },
+ ]
+}
+
+class TestRegistration2(unittest.TestCase):
+ def setUp(self):
+ self.client = Client()
+ self.view = registration.Registry()
+
+ def tearDown(self):
+ pass
+
+
+ def test_discover_flavors(self):
+ mock_session = test_base.get_mock_session(
+ ["get"], {"get": {
+ "content": MOCK_GET_FLAVOR_RESPONSE}}),
+
+ resp = self.view._discover_flavors(vimid="windriver-hudson-dc_RegionOne",
+ session=mock_session, viminfo=MOCK_VIM_INFO)
+
+ self.assertIsNone(resp)