summaryrefslogtreecommitdiffstats
path: root/windriver/titanium_cloud/vesagent/tests.py
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-06-15 13:58:25 +0800
committerYun Huang <yun.huang@windriver.com>2018-06-15 13:59:22 +0800
commit46c1ee7f60a93fe474cdb57618c80cb96a239f09 (patch)
tree233fcf5e716c31d02e433127f08d479d89372288 /windriver/titanium_cloud/vesagent/tests.py
parent4c6c154a941e275d601c0d7eee93231a49f2ec6c (diff)
Add test case for vesagent_ctrl
Change-Id: I733892bdb499d404761cf900ad44fc9ca0ad0133 Issue-ID: MULTICLOUD-230 Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'windriver/titanium_cloud/vesagent/tests.py')
-rw-r--r--windriver/titanium_cloud/vesagent/tests.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/windriver/titanium_cloud/vesagent/tests.py b/windriver/titanium_cloud/vesagent/tests.py
index 7026d569..520c8ace 100644
--- a/windriver/titanium_cloud/vesagent/tests.py
+++ b/windriver/titanium_cloud/vesagent/tests.py
@@ -21,7 +21,7 @@ from rest_framework import status
from django.core.cache import cache
from common.msapi import extsys
-
+from titanium_cloud.vesagent import vesagent_ctrl
MOCK_VIM_INFO = {
@@ -43,9 +43,11 @@ MOCK_VIM_INFO = {
'insecure': 'True',
}
+
class VesAgentCtrlTest(unittest.TestCase):
def setUp(self):
self.client = Client()
+ self.view = vesagent_ctrl.VesAgentCtrl()
def tearDown(self):
pass
@@ -58,3 +60,17 @@ class VesAgentCtrlTest(unittest.TestCase):
response = self.client.get("/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/vesagent")
self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)
+
+ @mock.patch.object(vesagent_ctrl.VesAgentCtrl, 'buildBacklogsOneVIM')
+ @mock.patch.object(extsys, 'get_vim_by_id')
+ def test_post(self, mock_get_vim_by_id, mock_buildBacklogsOneVIM):
+ mock_get_vim_by_id.return_value = MOCK_VIM_INFO
+ mock_buildBacklogsOneVIM.return_value = "mocked vesagent_backlogs"
+ mock_request = mock.Mock()
+ mock_request.META = {"testkey":"testvalue"}
+ mock_request.data = {"testdatakey":"testdatavalue"}
+
+ response = self.view.post(request=mock_request, vimid="windriver-hudson-dc_RegionOne")
+ self.assertEquals(status.HTTP_201_CREATED, response.status_code)
+
+ pass