From 96dbfd447a2fed0cea37e4a97435ce51219f9a6d Mon Sep 17 00:00:00 2001 From: Dave McCowan Date: Mon, 24 Aug 2015 09:23:36 -0400 Subject: [PATCH] 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 --- functionaltests/api/v1/behaviors/quota_behaviors.py | 5 +++-- functionaltests/api/v1/functional/test_quotas.py | 2 +- functionaltests/api/v1/functional/test_quotas_rbac.py | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/functionaltests/api/v1/behaviors/quota_behaviors.py b/functionaltests/api/v1/behaviors/quota_behaviors.py index 7054d9a55..bab5ff3f8 100644 --- a/functionaltests/api/v1/behaviors/quota_behaviors.py +++ b/functionaltests/api/v1/behaviors/quota_behaviors.py @@ -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) diff --git a/functionaltests/api/v1/functional/test_quotas.py b/functionaltests/api/v1/functional/test_quotas.py index d72d6a3ec..175e87338 100644 --- a/functionaltests/api/v1/functional/test_quotas.py +++ b/functionaltests/api/v1/functional/test_quotas.py @@ -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""" diff --git a/functionaltests/api/v1/functional/test_quotas_rbac.py b/functionaltests/api/v1/functional/test_quotas_rbac.py index dcc7b9c98..a1c4d39d6 100644 --- a/functionaltests/api/v1/functional/test_quotas_rbac.py +++ b/functionaltests/api/v1/functional/test_quotas_rbac.py @@ -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)