summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-07-04 18:17:28 +0800
committerYun Huang <yun.huang@windriver.com>2018-07-04 18:17:28 +0800
commit7671ba36f568d10da7c4febed40ce0ab1325f3fd (patch)
tree1fb1b20eaf807102408a81ed639bd7bf3d238ee9
parent425f1b854ae0db194beff9569bc05fbd585879fe (diff)
Add ocata UT for VESagent GET API
Change-Id: Ie6075fe0f2002a1c2de41fcd5538524ac344112c Issue-ID: MULTICLOUD-230 Signed-off-by: Yun Huang <yun.huang@windriver.com>
-rw-r--r--ocata/ocata/vesagent/tests.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/ocata/ocata/vesagent/tests.py b/ocata/ocata/vesagent/tests.py
new file mode 100644
index 00000000..b170e025
--- /dev/null
+++ b/ocata/ocata/vesagent/tests.py
@@ -0,0 +1,60 @@
+# 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
+
+
+
+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': '{"vesagent_config":{"backlogs":[{"source":"onap-aaf","domain":"fault","type":"vm","tenant":"VIM"}],"poll_interval_default":10,"ves_subscription":{"username":"user","password":"password","endpoint":"http://127.0.0.1:9005/sample"}}}',
+ 'cloud_epa_caps': '',
+ 'insecure': 'True',
+}
+
+class VesAgentCtrlTest(unittest.TestCase):
+ def setUp(self):
+ self.client = Client()
+
+ def tearDown(self):
+ pass
+
+ @mock.patch.object(cache, 'get')
+ @mock.patch.object(extsys, 'get_vim_by_id')
+ def test_get(self, mock_get_vim_by_id, mock_get):
+ mock_get_vim_by_id.return_value = MOCK_VIM_INFO
+ mock_get.return_value = '{"backlogs": [{"backlog_uuid": "2b8f6ff8-bc64-339b-a714-155909db937f", "server_id": "c4b575fa-ed85-4642-ab4b-335cb5744721", "tenant_id": "0e148b76ee8c42f78d37013bf6b7b1ae", "api_method": "GET", "source": "onap-aaf", "api_link": "/onaplab_RegionOne/compute/v2.1/0e148b76ee8c42f78d37013bf6b7b1ae/servers/c4b575fa-ed85-4642-ab4b-335cb5744721", "domain": "fault", "type": "vm", "tenant": "VIM"}], "poll_interval_default": 10, "vimid": "onaplab_RegionOne", "subscription": {"username": "user", "password": "password", "endpoint": "http://127.0.0.1:9005/sample"}}'
+
+ response = self.client.get("/api/multicloud-ocata/v0/windriver-hudson-dc_RegionOne/vesagent")
+ self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)