Separate negative tests for list_floating_ips

Add negative tests for test_list_floating_ips to a specific file.
Since no floating_ips are needed to setup for negative test,
generation of non existent id can be simplified.

bp negative-test-files

Change-Id: I1d3ac0956ea3f69bbd5bde897f0a18fc0e182930
This commit is contained in:
Adalberto Medeiros
2013-12-03 18:33:36 +00:00
parent 65841cf0a6
commit 981ab4c969
2 changed files with 48 additions and 22 deletions

View File

@@ -15,11 +15,7 @@
# 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
@@ -78,24 +74,6 @@ class FloatingIPDetailsTestJSON(base.BaseV2ComputeTest):
finally:
self.client.delete_floating_ip(floating_ip_id)
@attr(type=['negative', 'gate'])
def test_get_nonexistant_floating_ip_details(self):
# Negative test:Should not be able to GET the details
# of non-existent floating IP
floating_ip_id = []
resp, body = self.client.list_floating_ips()
for i in range(len(body)):
floating_ip_id.append(body[i]['id'])
# Creating a non-existent floatingIP id
while True:
non_exist_id = data_utils.rand_int_id(start=999)
if self.config.service_available.neutron:
non_exist_id = str(uuid.uuid4())
if non_exist_id not in floating_ip_id:
break
self.assertRaises(exceptions.NotFound,
self.client.get_floating_ip_details, non_exist_id)
@attr(type='gate')
def test_list_floating_ip_pools(self):
# Positive test:Should return the list of floating IP Pools

View File

@@ -0,0 +1,48 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 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 FloatingIPDetailsNegativeTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
super(FloatingIPDetailsNegativeTestJSON, cls).setUpClass()
cls.client = cls.floating_ips_client
@attr(type=['negative', 'gate'])
def test_get_nonexistent_floating_ip_details(self):
# Negative test:Should not be able to GET the details
# of non-existent floating IP
# Creating a non-existent floatingIP id
if self.config.service_available.neutron:
non_exist_id = str(uuid.uuid4())
else:
non_exist_id = data_utils.rand_int_id(start=999)
self.assertRaises(exceptions.NotFound,
self.client.get_floating_ip_details, non_exist_id)
class FloatingIPDetailsNegativeTestXML(FloatingIPDetailsNegativeTestJSON):
_interface = 'xml'