Remove useless API tests

The 'test_flavor_swap' tests are validating behavior that's already
validated by the larger 'test_flavors' tests and a plethora of
functional tests. This is legacy from the time where exposing 'swap' was
required the 'os-flavor-swap' extension [1]. This extension was not
ported to v2.1 [2] and 'swap' is now part of the default response.

Stop special casing these particular fields.

[1] https://github.com/openstack/nova/commit/81dd5b78
[2] https://github.com/openstack/nova/commit/a31d917a

Change-Id: I55a57b76a92677fbe7db9b6ef91f8cd4daf30d87
This commit is contained in:
Stephen Finucane 2017-04-28 13:05:11 +01:00
parent 6e64cb032e
commit 26117cf544
1 changed files with 0 additions and 62 deletions

View File

@ -1,62 +0,0 @@
# Copyright 2012 Nebula, 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. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_serialization import jsonutils
from nova import test
from nova.tests.unit.api.openstack import fakes
class FlavorSwapTestV21(test.NoDBTestCase):
base_url = '/v2/fake/flavors'
content_type = 'application/json'
prefix = ''
def setUp(self):
super(FlavorSwapTestV21, self).setUp()
fakes.stub_out_nw_api(self)
fakes.stub_out_flavor_get_all(self)
fakes.stub_out_flavor_get_by_flavor_id(self)
def _make_request(self, url):
req = fakes.HTTPRequest.blank(url)
req.headers['Accept'] = self.content_type
res = req.get_response(fakes.wsgi_app_v21())
return res
def _get_flavor(self, body):
return jsonutils.loads(body).get('flavor')
def _get_flavors(self, body):
return jsonutils.loads(body).get('flavors')
def assertFlavorSwap(self, flavor, swap):
self.assertEqual(flavor.get('%sswap' % self.prefix), swap)
def test_show(self):
url = self.base_url + '/1'
res = self._make_request(url)
self.assertEqual(res.status_int, 200)
self.assertFlavorSwap(self._get_flavor(res.body),
fakes.FLAVORS['1'].swap)
def test_detail(self):
url = self.base_url + '/detail'
res = self._make_request(url)
self.assertEqual(res.status_int, 200)
flavors = self._get_flavors(res.body)
self.assertFlavorSwap(flavors[0], fakes.FLAVORS['1'].swap)
self.assertFlavorSwap(flavors[1], fakes.FLAVORS['2'].swap)