diff options
author | Huang Haibin <haibin.huang@intel.com> | 2018-09-11 20:23:46 +0800 |
---|---|---|
committer | Huang Haibin <haibin.huang@intel.com> | 2018-09-11 20:23:46 +0800 |
commit | f68bb797597444c3867fe7be2f97423468d966b9 (patch) | |
tree | 8e85cf94955c0df500a4d62e0898a799dc66d5a4 /ocata | |
parent | e7f5aba1d5d92a00a7b1689bf0c4b9f09696c9fe (diff) |
Test case for buildBacklogsOneVIM in ocata
Change-Id: If6ceaec671fcf4e57c26c695a373ab2a8d113041
Issue-ID: MULTICLOUD-230
Signed-off-by: Huang Haibin <haibin.huang@intel.com>
Diffstat (limited to 'ocata')
-rw-r--r-- | ocata/ocata/vesagent/tests.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/ocata/ocata/vesagent/tests.py b/ocata/ocata/vesagent/tests.py index 49521382..242f7d19 100644 --- a/ocata/ocata/vesagent/tests.py +++ b/ocata/ocata/vesagent/tests.py @@ -22,7 +22,7 @@ from rest_framework import status from django.core.cache import cache from common.msapi import extsys from ocata.vesagent import vesagent_ctrl - +from ocata.vesagent.tasks import scheduleBacklogs MOCK_VIM_INFO = { @@ -124,3 +124,31 @@ class VesAgentCtrlTest(unittest.TestCase): pass + + @mock.patch.object(scheduleBacklogs, 'delay') + @mock.patch.object(cache, 'set') + @mock.patch.object(cache, 'get') + def test_buildBacklogsOneVIM(self, mock_get, mock_set, mock_scheduleBacklogs_delay): + mock_VesAgentBacklogs_vimlist = ["windriver-hudson-dc_RegionOne"] + mock_vesagent_config = {"backlogs": [{"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"}], + "poll_interval_default": 10, "vimid": "windriver-hudson-dc_RegionOne", + "ves_subscription": {"username": "user", "password": "password", + "endpoint": "http://127.0.0.1:9005/sample"}} + + mock_get.side_effect= [ + json.dumps(mock_VesAgentBacklogs_vimlist), + ] + + mock_set.return_value = "mocked cache set" + mock_scheduleBacklogs_delay.return_value = "mocked delay" + + VesAgentBacklogsConfig = self.view.buildBacklogsOneVIM(vimid="windriver-hudson-dc_RegionOne", + vesagent_config = mock_vesagent_config) + self.assertIsNotNone(VesAgentBacklogsConfig) + + pass |