Fix the network quota tests

These network quota tests were badly broken.  I simplified them
up a lot so they will require less maintenance.

Change-Id: I9738b9283de2e731510f6ed5ff208c075ea48940
Partial-bug: #1665495
This commit is contained in:
Terry Howe 2017-02-18 17:10:22 -07:00
parent 52bd73e45d
commit f5e77c6be9
2 changed files with 24 additions and 16 deletions

View File

@ -5,6 +5,7 @@
#
mkdir -p ~/.config/openstack/
FILE=~/.config/openstack/clouds.yaml
export OS_IDENTITY_API_VERSION=3 # force v3 identity
echo 'clouds:' >$FILE
echo ' test_cloud:' >>$FILE
env | grep OS_ | tr '=' ' ' | while read k v

View File

@ -10,27 +10,34 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
from openstack.tests.functional import base
class TestQuota(base.BaseFunctionalTest):
PROJECT_NAME = 'project-' + uuid.uuid4().hex
PROJECT = None
@classmethod
def setUpClass(cls):
super(TestQuota, cls).setUpClass()
# Need a project to have a quota
cls.PROJECT = cls.conn.identity.create_project(name=cls.PROJECT_NAME)
@classmethod
def tearDownClass(cls):
cls.conn.identity.delete_project(cls.PROJECT.id)
def test_list(self):
sot = self.conn.network.quotas()
for qot in sot:
self.assertIn('subnet', qot)
self.assertIn('network', qot)
self.assertIn('router', qot)
self.assertIn('port', qot)
self.assertIn('floatingip', qot)
self.assertIn('security_group_rule', qot)
self.assertIn('security_group', qot)
self.assertIn('subnetpool', qot)
self.assertIn('rbac_policy', qot)
qot = self.conn.network.quotas().next()
self.assertIsNotNone(qot.project_id)
self.assertIsNotNone(qot.networks)
def test_set(self):
attrs = {'network': 123456789}
self.conn.network.update_quota(**attrs)
quota_list = self.conn.network.get_quota()
for quota in quota_list:
self.assertIn('123456789', quota)
attrs = {'networks': 123456789}
project_quota = self.conn.network.quotas().next()
self.conn.network.update_quota(project_quota, **attrs)
new_quota = self.conn.network.get_quota(project_quota.project_id)
self.assertEqual(123456789, new_quota.networks)