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:
|
except Exception:
|
||||||
return utils.format_nova_error(500, _('Failed to delete flavor'))
|
return utils.format_nova_error(500, _('Failed to delete flavor'))
|
||||||
pecan.response.status = 202
|
pecan.response.status = 202
|
||||||
return
|
return pecan.response
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from mock import patch
|
from mock import patch
|
||||||
|
import pecan
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from trio2o.common import context
|
from trio2o.common import context
|
||||||
@ -21,6 +22,10 @@ from trio2o.db import core
|
|||||||
from trio2o.nova_apigw.controllers import flavor
|
from trio2o.nova_apigw.controllers import flavor
|
||||||
|
|
||||||
|
|
||||||
|
class FakeResponse(object):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class FlavorTest(unittest.TestCase):
|
class FlavorTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
core.initialize()
|
core.initialize()
|
||||||
@ -29,6 +34,7 @@ class FlavorTest(unittest.TestCase):
|
|||||||
self.project_id = 'test_project'
|
self.project_id = 'test_project'
|
||||||
self.controller = flavor.FlavorController(self.project_id)
|
self.controller = flavor.FlavorController(self.project_id)
|
||||||
|
|
||||||
|
@patch.object(pecan, 'response', new=FakeResponse)
|
||||||
@patch.object(context, 'extract_context_from_environ')
|
@patch.object(context, 'extract_context_from_environ')
|
||||||
def test_post(self, mock_context):
|
def test_post(self, mock_context):
|
||||||
mock_context.return_value = self.context
|
mock_context.return_value = self.context
|
||||||
@ -42,6 +48,8 @@ class FlavorTest(unittest.TestCase):
|
|||||||
self.assertEqual(1024, flavor_dict['memory_mb'])
|
self.assertEqual(1024, flavor_dict['memory_mb'])
|
||||||
self.assertEqual(1, flavor_dict['vcpus'])
|
self.assertEqual(1, flavor_dict['vcpus'])
|
||||||
self.assertEqual(10, flavor_dict['root_gb'])
|
self.assertEqual(10, flavor_dict['root_gb'])
|
||||||
|
res = self.controller.delete('1')
|
||||||
|
self.assertEqual(202, res.status)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
core.ModelBase.metadata.drop_all(core.get_engine())
|
core.ModelBase.metadata.drop_all(core.get_engine())
|
||||||
|
Loading…
Reference in New Issue
Block a user