diff options
author | Ethan Lynn <ethanlynnl@vmware.com> | 2018-03-04 21:51:01 +0000 |
---|---|---|
committer | Ethan Lynn <ethanlynnl@vmware.com> | 2018-03-19 15:42:19 +0800 |
commit | 9a0d43b54519c8e08683e522255370ccba137902 (patch) | |
tree | 81864d6b75f5d79b9d4cbbc15b95353332a9a3f3 /multivimbroker | |
parent | dbbd44d10bcfc3143fb2d227a702ab5588ad0702 (diff) |
Add test_check_capacity_success
Add test_check_capacity_success for check_vim_capacity API
Change-Id: I8b0ffb3b907b25f06d8267c7ec941ce83d636d95
Issue-ID: MULTICLOUD-166
Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
Diffstat (limited to 'multivimbroker')
-rw-r--r-- | multivimbroker/multivimbroker/tests/test_check_capacity.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/multivimbroker/multivimbroker/tests/test_check_capacity.py b/multivimbroker/multivimbroker/tests/test_check_capacity.py new file mode 100644 index 0000000..0a852e8 --- /dev/null +++ b/multivimbroker/multivimbroker/tests/test_check_capacity.py @@ -0,0 +1,54 @@ +# Copyright (c) 2017-2018 VMware, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +import mock +import unittest + +from rest_framework import status + +from multivimbroker.forwarder.views import CheckCapacity + + +class CheckCapacityTest(unittest.TestCase): + + def setUp(self): + self.view = CheckCapacity() + super(CheckCapacityTest, self).setUp() + + def tearDown(self): + pass + + def test_check_capacity_success(self): + req = mock.Mock() + req.body = """ + { + "vCPU": 1, + "Memory": 1, + "Storage": 500, + "VIMs": ["openstack_RegionOne"] + }""" + req.get_full_path.return_value = ("http://msb.onap.org/api/multicloud" + "/v0/check_vim_capacity") + with mock.patch.object(self.view, "send") as send: + plugin_resp = mock.Mock() + plugin_resp.body = """{ + "result": true + }""" + plugin_resp.status_code = status.HTTP_200_OK + send.return_value = plugin_resp + + resp = self.view.post(req) + expect_body = { + "VIMs": ["openstack_RegionOne"] + } + self.assertEqual(status.HTTP_200_OK, resp.status_code) + self.assertDictEqual(expect_body, resp.data) |