summaryrefslogtreecommitdiffstats
path: root/ocata
diff options
context:
space:
mode:
authorHuang Haibin <haibin.huang@intel.com>2018-09-11 16:36:48 +0800
committerHuang Haibin <haibin.huang@intel.com>2018-09-11 16:36:48 +0800
commit6f159298aa0792512f22366d776ed13f62e77117 (patch)
tree60e2b372fd97a15649d1d0c42d836d735ba66389 /ocata
parent666db995112ea06f1648c1e6c61631b9f551e19d (diff)
Add test case for vesagent_ctrl in ocata
Change-Id: I3e4541b2e4ec55aa8cb5942a3dd979b1256042cc Issue-ID: MULTICLOUD-230 Signed-off-by: Huang Haibin <haibin.huang@intel.com>
Diffstat (limited to 'ocata')
-rw-r--r--ocata/ocata/vesagent/tests.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/ocata/ocata/vesagent/tests.py b/ocata/ocata/vesagent/tests.py
index 9f34b3f5..4f6d58fb 100644
--- a/ocata/ocata/vesagent/tests.py
+++ b/ocata/ocata/vesagent/tests.py
@@ -21,6 +21,7 @@ from rest_framework import status
from django.core.cache import cache
from common.msapi import extsys
+from ocata.vesagent import vesagent_ctrl
@@ -45,6 +46,7 @@ MOCK_VIM_INFO = {
class VesAgentCtrlTest(unittest.TestCase):
def setUp(self):
self.client = Client()
+ self.view = vesagent_ctrl.VesAgentCtrl()
def tearDown(self):
pass
@@ -57,3 +59,17 @@ class VesAgentCtrlTest(unittest.TestCase):
response = self.client.get("/api/multicloud-ocata/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