From: Jakub Libosvar Date: Tue, 18 Aug 2015 15:05:21 +0000 (+0000) Subject: fullstack: Skip NotFound in safe_client cleanup X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=a84216b1e0df6cab917e1f6a0af55a8372093ba0;p=openstack-build%2Fneutron-build.git fullstack: Skip NotFound in safe_client cleanup If we explicitly remove resource in the test we don't need to fail in safe_client during cleanup phase. Change-Id: Ia3b0756b7aa9b159de1949889ae03ca5248bc5fa Closes-Bug: 1486081 --- diff --git a/neutron/tests/fullstack/resources/client.py b/neutron/tests/fullstack/resources/client.py index 42350793c..2297b5f0c 100644 --- a/neutron/tests/fullstack/resources/client.py +++ b/neutron/tests/fullstack/resources/client.py @@ -12,12 +12,24 @@ # License for the specific language governing permissions and limitations # under the License. # +import functools import fixtures +from neutronclient.common import exceptions from neutron.tests import base +def _safe_method(f): + @functools.wraps(f) + def delete(*args, **kwargs): + try: + return f(*args, **kwargs) + except exceptions.NotFound: + pass + return delete + + class ClientFixture(fixtures.Fixture): """Manage and cleanup neutron resources.""" @@ -32,7 +44,7 @@ class ClientFixture(fixtures.Fixture): body = {resource_type: spec} resp = create(body=body) data = resp[resource_type] - self.addCleanup(delete, data['id']) + self.addCleanup(_safe_method(delete), data['id']) return data def create_router(self, tenant_id, name=None, ha=False): @@ -68,5 +80,5 @@ class ClientFixture(fixtures.Fixture): def add_router_interface(self, router_id, subnet_id): body = {'subnet_id': subnet_id} self.client.add_interface_router(router=router_id, body=body) - self.addCleanup(self.client.remove_interface_router, + self.addCleanup(_safe_method(self.client.remove_interface_router), router=router_id, body=body)