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 <zhangchi@szzt.com.cn> co-Authored-By: tangzhuo <ztang@hnu.edu.cn> Change-Id: I16873ecd4002abdaf214b29c6bec199e7958b443
This commit is contained in:
parent
d2814db497
commit
974c08d081
@ -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
|
||||
|
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user