From f5e77c6be9b3c33b8031c310526bbebbfbd7aee8 Mon Sep 17 00:00:00 2001 From: Terry Howe Date: Sat, 18 Feb 2017 17:10:22 -0700 Subject: [PATCH] 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 --- create_yaml.sh | 1 + .../tests/functional/network/v2/test_quota.py | 39 +++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/create_yaml.sh b/create_yaml.sh index 3da207841..4443986ee 100755 --- a/create_yaml.sh +++ b/create_yaml.sh @@ -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 diff --git a/openstack/tests/functional/network/v2/test_quota.py b/openstack/tests/functional/network/v2/test_quota.py index 17f1fbb29..b02f18f4b 100644 --- a/openstack/tests/functional/network/v2/test_quota.py +++ b/openstack/tests/functional/network/v2/test_quota.py @@ -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)