Cleanup database after functional test runs

Ensure all quota related database entries are deleted after
running functional tests.

Change-Id: Ib51bc66cab7c173cf8d7e77a587d599100b70386
Implements: blueprint quota-support-on-barbican-resources
This commit is contained in:
Dave McCowan 2015-08-24 09:23:36 -04:00
parent 9835bd0027
commit 96dbfd447a
3 changed files with 10 additions and 3 deletions

View File

@ -101,7 +101,8 @@ class QuotaBehaviors(base_behaviors.BaseBehaviors):
extra_headers=extra_headers,
use_auth=use_auth, user_name=user_name)
self.created_entities.append((project_id, user_name))
if resp.status_code == 204:
self.created_entities.append((project_id, user_name))
return resp
@ -120,7 +121,7 @@ class QuotaBehaviors(base_behaviors.BaseBehaviors):
extra_headers=extra_headers,
use_auth=use_auth, user_name=user_name)
if not expected_fail:
if resp.status_code == 204:
for item in self.created_entities:
if item[0] == project_id:
self.created_entities.remove(item)

View File

@ -39,8 +39,8 @@ class QuotasTestCase(base.TestCase):
CONF.identity.username)
def tearDown(self):
super(QuotasTestCase, self).tearDown()
self.behaviors.delete_all_created_quotas()
super(QuotasTestCase, self).tearDown()
def test_get_quotas_with_defaults(self):
"""Get effective quota information for own project"""

View File

@ -98,6 +98,7 @@ class RBACQuotasTestCase(base.TestCase):
self.project_id = self.behaviors.get_project_id_from_name('admin')
def tearDown(self):
self.behaviors.delete_all_created_quotas()
super(RBACQuotasTestCase, self).tearDown()
@utils.parameterized_dataset(test_data_rbac_get_quotas)
@ -157,6 +158,11 @@ class RBACQuotasTestCase(base.TestCase):
:param admin: the admin of the group owning quotas
:param expected_return: the expected http return code
"""
request_model = quota_models.ProjectQuotaRequestModel(
**get_set_project_quotas_request())
resp = self.behaviors.set_project_quotas(
self.project_id, request_model,
user_name=CONF.identity.service_admin)
resp = self.behaviors.delete_project_quotas(self.project_id,
user_name=user)
self.assertEqual(expected_return, resp.status_code)