Remove legacy v2 unit tests[a-e]

There are two implementation code for similar API in Nova repository.
One is newer: v2.1 API, another is legacy: v2 API. v2.1 API has been
 used as the default API since Liberty and legacy v2 API has been marked
as deprecated. We have used and tested v2.1 API so well and now is nice
time to remove legacy API code based on the consensus of the design
summit of Austin.

This patch removes unit tests of legacy v2 API[a-e].

NOTE: Two test modules test_extended_rescue_with_image and
      test_extended_virtual_interfaces_net are just removed
      because the corresponding modules exist on legacy v2
      code only. These modules are merged into source modules
      on v2.1 code.

Partially implements blueprint remove-legacy-v2-api-code

Change-Id: Icd57f5b1718faef3ab7afe4acd34e56d4d29a3a8
This commit is contained in:
Ken'ichi Ohmichi 2016-05-01 20:45:29 -07:00
parent 7049ca9e52
commit 169bd0eaf4

View File

@ -20,8 +20,6 @@ import uuid
from webob import exc
from nova.api.openstack.compute import aggregates as aggregates_v21
from nova.api.openstack.compute.legacy_v2.contrib import aggregates \
as aggregates_v2
from nova.compute import api as compute_api
from nova import context
from nova import exception
@ -745,78 +743,3 @@ class AggregateTestCaseV21(test.NoDBTestCase):
def _assert_agg_data(self, expected, actual):
self.assertTrue(obj_base.obj_equal_prims(expected, actual),
"The aggregate objects were not equal")
class AggregateTestCaseV2(AggregateTestCaseV21):
add_host = 'self.controller.action'
remove_host = 'self.controller.action'
set_metadata = 'self.controller.action'
bad_request = exc.HTTPBadRequest
def _set_up(self):
self.controller = aggregates_v2.AggregateController()
self.req = FakeRequest()
self.user_req = fakes.HTTPRequest.blank('/v2/os-aggregates')
self.context = self.req.environ['nova.context']
def test_add_host_raises_key_error(self):
def stub_add_host_to_aggregate(context, aggregate, host):
raise KeyError
self.stubs.Set(self.controller.api, "add_host_to_aggregate",
stub_add_host_to_aggregate)
# NOTE(mtreinish) The check for a KeyError here is to ensure that
# if add_host_to_aggregate() raises a KeyError it propagates. At
# one point the api code would mask the error as a HTTPBadRequest.
# This test is to ensure that this doesn't occur again.
self.assertRaises(KeyError, eval(self.add_host), self.req, "1",
body={"add_host": {"host": "host1"}})
def test_add_host_to_aggregate_with_non_admin(self):
rule_name = "compute_extension:aggregates"
self.policy.set_rules({rule_name: ""})
self.assertRaises(exception.AdminRequired, self.controller._add_host,
self.user_req, '1', {'host': 'fake_host'})
def test_remove_host_from_aggregate_with_non_admin(self):
rule_name = "compute_extension:aggregates"
self.policy.set_rules({rule_name: ""})
self.assertRaises(exception.AdminRequired,
self.controller._remove_host, self.user_req,
'1', {'host': 'fake_host'})
def test_create_name_with_leading_trailing_spaces(self):
def fake_mock_aggs(context, name, az):
# NOTE(alex_xu): legacy v2 api didn't strip the spaces.
self.assertEqual(' test ', name)
return AGGREGATE
with mock.patch.object(compute_api.AggregateAPI,
'create_aggregate') as mock_aggs:
mock_aggs.side_effect = fake_mock_aggs
self.controller.create(self.req,
body={"aggregate":
{"name": " test ",
"availability_zone": "nova1"}})
def test_create_name_with_leading_trailing_spaces_compat_mode(self):
pass
def test_create_availability_zone_with_leading_trailing_spaces(self):
def fake_mock_aggs(context, name, az):
# NOTE(alex_xu): legacy v2 api didn't strip the spaces.
self.assertEqual(' nova1 ', az)
return AGGREGATE
with mock.patch.object(compute_api.AggregateAPI,
'create_aggregate') as mock_aggs:
mock_aggs.side_effect = fake_mock_aggs
self.controller.create(self.req,
body={"aggregate":
{"name": " test ",
"availability_zone": " nova1 "}})
def test_create_availabiltiy_zone_with_leading_trailing_spaces_compat_mode(
self):
pass