summaryrefslogtreecommitdiffstats
path: root/ocata
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-07-04 18:37:50 +0800
committerYun Huang <yun.huang@windriver.com>2018-07-04 18:37:50 +0800
commit59680b9172a05cad9a4a1490457cc7a2524a3c12 (patch)
tree0aa2b612bb9e722a705608eb2f83555f94649801 /ocata
parent48120d383ffb4b925862f015d4fe132967d16d5a (diff)
Add UT for vesagent tasks_processBacklogsOfOneVIM
Change-Id: I9abf1cb8d2a8fb977e10a14d6ba2dd700d8c8107 Issue-ID: MULTICLOUD-230 Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'ocata')
-rw-r--r--ocata/ocata/vesagent/tests_tasks.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/ocata/ocata/vesagent/tests_tasks.py b/ocata/ocata/vesagent/tests_tasks.py
index e1e3c5c8..82cc59c9 100644
--- a/ocata/ocata/vesagent/tests_tasks.py
+++ b/ocata/ocata/vesagent/tests_tasks.py
@@ -80,3 +80,27 @@ class VesTaskTest(unittest.TestCase):
self.assertEquals(COUNT_TIME_SLOT_ONE_VIM, result)
pass
+ @mock.patch.object(tasks, 'processOneBacklog')
+ @mock.patch.object(cache, 'set')
+ @mock.patch.object(cache, 'get')
+ def test_tasks_processBacklogsOfOneVIM(self, mock_cache_get, mock_cache_set, mock_tasks_processOneBacklog):
+ 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": "onaplab_RegionOne",
+ "subscription": {"username": "user", "password": "password",
+ "endpoint": "http://127.0.0.1:9005/sample"}}
+ mock_cache_get.side_effect= [
+ json.dumps(mock_vesagent_config),
+ json.dumps({})
+ ]
+ mock_tasks_processOneBacklog.return_value = (1, 11)
+ mock_cache_set.return_value = "mocked cache set"
+ result = tasks.processBacklogsOfOneVIM(vimid="windriver-hudson-dc_RegionOne")
+ COUNT_TIME_SLOT = (1, 10)
+ self.assertEquals(COUNT_TIME_SLOT, result)
+ pass