Merge "Separate negative tests in flavors/test_flavors"

This commit is contained in:
Jenkins
2013-12-12 08:58:42 +00:00
committed by Gerrit Code Review
2 changed files with 69 additions and 25 deletions

View File

@@ -16,7 +16,6 @@
# under the License.
from tempest.api.compute import base
from tempest import exceptions
from tempest.test import attr
@@ -50,12 +49,6 @@ class FlavorsTestJSON(base.BaseV2ComputeTest):
resp, flavor = self.client.get_flavor_details(self.flavor_ref)
self.assertEqual(self.flavor_ref, flavor['id'])
@attr(type=['negative', 'gate'])
def test_get_non_existant_flavor(self):
# flavor details are not returned for non-existent flavors
self.assertRaises(exceptions.NotFound, self.client.get_flavor_details,
999)
@attr(type='gate')
def test_list_flavors_limit_results(self):
# Only the expected number of flavors should be returned
@@ -136,24 +129,6 @@ class FlavorsTestJSON(base.BaseV2ComputeTest):
resp, flavors = self.client.list_flavors(params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
@attr(type=['negative', 'gate'])
def test_invalid_minRam_filter(self):
self.assertRaises(exceptions.BadRequest,
self.client.list_flavors_with_detail,
{'minRam': 'invalid'})
@attr(type=['negative', 'gate'])
def test_invalid_minDisk_filter(self):
self.assertRaises(exceptions.BadRequest,
self.client.list_flavors_with_detail,
{'minDisk': 'invalid'})
@attr(type=['negative', 'gate'])
def test_get_flavor_details_for_invalid_flavor_id(self):
# Ensure 404 returned for non-existent flavor ID
self.assertRaises(exceptions.NotFound, self.client.get_flavor_details,
9999)
class FlavorsTestXML(FlavorsTestJSON):
_interface = 'xml'

View File

@@ -0,0 +1,69 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
# 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.
import uuid
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import exceptions
from tempest.test import attr
class FlavorsNegativeTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
super(FlavorsNegativeTestJSON, cls).setUpClass()
cls.client = cls.flavors_client
# Generating a nonexistent flavor id
resp, flavors = cls.client.list_flavors()
flavor_ids = [flavor['id'] for flavor in flavors]
while True:
cls.nonexistent_flavor_id = data_utils.rand_int_id(start=999)
if cls.nonexistent_flavor_id not in flavor_ids:
break
@attr(type=['negative', 'gate'])
def test_invalid_minRam_filter(self):
self.assertRaises(exceptions.BadRequest,
self.client.list_flavors_with_detail,
{'minRam': 'invalid'})
@attr(type=['negative', 'gate'])
def test_invalid_minDisk_filter(self):
self.assertRaises(exceptions.BadRequest,
self.client.list_flavors_with_detail,
{'minDisk': 'invalid'})
@attr(type=['negative', 'gate'])
def test_get_flavor_details_for_invalid_flavor_id(self):
# Ensure 404 returned for invalid flavor ID
invalid_flavor_id = str(uuid.uuid4())
self.assertRaises(exceptions.NotFound, self.client.get_flavor_details,
invalid_flavor_id)
@attr(type=['negative', 'gate'])
def test_non_existent_flavor_id(self):
# flavor details are not returned for non-existent flavors
self.assertRaises(exceptions.NotFound, self.client.get_flavor_details,
self.nonexistent_flavor_id)
class FlavorsNegativeTestXML(FlavorsNegativeTestJSON):
_interface = 'xml'