From 974c08d08191d4843fa1059a617cf0c81627e395 Mon Sep 17 00:00:00 2001 From: BruceChiZhang Date: Fri, 31 Aug 2018 17:45:22 +0800 Subject: [PATCH] add delete flavor test case for trio2o 1. what is the problem? flavors case has not finished 2. What is the solution to the problem? complete the test finished create all flavors 3. What the features to be implemented in the Trio2o to realize the solution? Signed-off-by: zhangchi co-Authored-By: tangzhuo Change-Id: I16873ecd4002abdaf214b29c6bec199e7958b443 --- trio2o/nova_apigw/controllers/flavor.py | 2 +- trio2o/tests/unit/nova_apigw/controllers/test_flavor.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/trio2o/nova_apigw/controllers/flavor.py b/trio2o/nova_apigw/controllers/flavor.py index bc332f4..94d3c1a 100644 --- a/trio2o/nova_apigw/controllers/flavor.py +++ b/trio2o/nova_apigw/controllers/flavor.py @@ -214,4 +214,4 @@ class FlavorController(rest.RestController): except Exception: return utils.format_nova_error(500, _('Failed to delete flavor')) pecan.response.status = 202 - return + return pecan.response diff --git a/trio2o/tests/unit/nova_apigw/controllers/test_flavor.py b/trio2o/tests/unit/nova_apigw/controllers/test_flavor.py index 403064b..29fd275 100644 --- a/trio2o/tests/unit/nova_apigw/controllers/test_flavor.py +++ b/trio2o/tests/unit/nova_apigw/controllers/test_flavor.py @@ -14,6 +14,7 @@ # under the License. from mock import patch +import pecan import unittest from trio2o.common import context @@ -21,6 +22,10 @@ from trio2o.db import core from trio2o.nova_apigw.controllers import flavor +class FakeResponse(object): + pass + + class FlavorTest(unittest.TestCase): def setUp(self): core.initialize() @@ -29,6 +34,7 @@ class FlavorTest(unittest.TestCase): self.project_id = 'test_project' self.controller = flavor.FlavorController(self.project_id) + @patch.object(pecan, 'response', new=FakeResponse) @patch.object(context, 'extract_context_from_environ') def test_post(self, mock_context): mock_context.return_value = self.context @@ -42,6 +48,8 @@ class FlavorTest(unittest.TestCase): self.assertEqual(1024, flavor_dict['memory_mb']) self.assertEqual(1, flavor_dict['vcpus']) self.assertEqual(10, flavor_dict['root_gb']) + res = self.controller.delete('1') + self.assertEqual(202, res.status) def tearDown(self): core.ModelBase.metadata.drop_all(core.get_engine())