summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-06-15 14:20:20 +0800
committerYun Huang <yun.huang@windriver.com>2018-06-15 14:20:20 +0800
commit15895735a754280800c37f88266856fb5da6a8e3 (patch)
treee1f041448f8490c96f3d2f356fa266cf49f23068
parent6cfb44195ad3fc40f113395fb54c7d5113527762 (diff)
Test case for test_buildBacklog
Change-Id: Ic77d4ce1c1c76c853dd89d5c402f0df5d64887c2 Issue-ID: MULTICLOUD-230 Signed-off-by: Yun Huang <yun.huang@windriver.com>
-rw-r--r--windriver/titanium_cloud/vesagent/tests.py21
-rw-r--r--windriver/titanium_cloud/vesagent/vesagent_ctrl.py4
2 files changed, 23 insertions, 2 deletions
diff --git a/windriver/titanium_cloud/vesagent/tests.py b/windriver/titanium_cloud/vesagent/tests.py
index 5c4348c2..a98177b2 100644
--- a/windriver/titanium_cloud/vesagent/tests.py
+++ b/windriver/titanium_cloud/vesagent/tests.py
@@ -22,6 +22,8 @@ from rest_framework import status
from django.core.cache import cache
from common.msapi import extsys
from titanium_cloud.vesagent import vesagent_ctrl
+from titanium_cloud.vesagent.event_domain import fault_vm
+
MOCK_VIM_INFO = {
@@ -154,3 +156,22 @@ class VesAgentCtrlTest(unittest.TestCase):
self.assertIsNotNone(VesAgentBacklogsConfig)
pass
+
+
+ @mock.patch.object(fault_vm, 'buildBacklog_fault_vm')
+ def test_buildBacklog(self, mock_buildBacklog_fault_vm):
+ mock_backlog_input = {"backlog_uuid": "ce2d7597-22e1-4239-890f-bc303bd67076",
+ "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"}
+
+
+ mock_buildBacklog_fault_vm.return_value = "mocked buildBacklog_fault_vm"
+
+ VesAgentBacklogsConfig = self.view.buildBacklog(vimid="windriver-hudson-dc_RegionOne",
+ backlog_input = mock_backlog_input)
+ self.assertIsNotNone(VesAgentBacklogsConfig)
+
+ pass
diff --git a/windriver/titanium_cloud/vesagent/vesagent_ctrl.py b/windriver/titanium_cloud/vesagent/vesagent_ctrl.py
index fbdd93f8..54b770bf 100644
--- a/windriver/titanium_cloud/vesagent/vesagent_ctrl.py
+++ b/windriver/titanium_cloud/vesagent/vesagent_ctrl.py
@@ -23,7 +23,7 @@ from rest_framework.views import APIView
from django.conf import settings
from common.msapi import extsys
from titanium_cloud.vesagent.tasks import scheduleBacklogs
-from titanium_cloud.vesagent.event_domain.fault_vm import buildBacklog_fault_vm
+from titanium_cloud.vesagent.event_domain import fault_vm
from django.core.cache import cache
@@ -393,7 +393,7 @@ class VesAgentCtrl(APIView):
try:
if backlog_input["domain"] == "fault" and backlog_input["type"] == "vm":
- return buildBacklog_fault_vm(vimid, backlog_input)
+ return fault_vm.buildBacklog_fault_vm(vimid, backlog_input)
else:
self._logger.warn("return with failure: unsupported backlog domain:%s, type:%s"
% (backlog_input["domain"], backlog_input["type"] == "vm"))