From: Maru Newby Date: Tue, 20 Jan 2015 02:23:48 +0000 (+0000) Subject: Switch to using abc in the retargetable client X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=37aec6d5072a7b2a79c2300d7a2e6f97811fc21a;p=openstack-build%2Fneutron-build.git Switch to using abc in the retargetable client abc is preferable to raising NotImplementedError because it will prevent instantiation of a subclass that doesn't implement the required methods rather than failing only when a missing method is called. Change-Id: I1043eefde675dd3b653d5b508be22cfd52d2fe8f Implements: bp retargetable-functional-testing --- diff --git a/neutron/tests/api/base_v2.py b/neutron/tests/api/base_v2.py index 5b3a2eae9..2a59e8df7 100644 --- a/neutron/tests/api/base_v2.py +++ b/neutron/tests/api/base_v2.py @@ -47,6 +47,9 @@ Examples of use include: Reference: https://pypi.python.org/pypi/testscenarios/ """ +import abc + +import six import testtools from neutron.tests import sub_base @@ -65,6 +68,7 @@ class AttributeDict(dict): raise AttributeError(_("Unknown attribute '%s'.") % name) +@six.add_metaclass(abc.ABCMeta) class BaseNeutronClient(object): """ Base class for a client that can interact the neutron api in some @@ -80,30 +84,34 @@ class BaseNeutronClient(object): """ self.test_case = test_case - @property + @abc.abstractproperty def NotFound(self): """The exception that indicates a resource could not be found. Tests can use this property to assert for a missing resource in a client-agnostic way. """ - raise NotImplementedError() + @abc.abstractmethod def create_network(self, **kwargs): - raise NotImplementedError() + pass + @abc.abstractmethod def update_network(self, id_, **kwargs): - raise NotImplementedError() + pass + @abc.abstractmethod def get_network(self, id_, fields=None): - raise NotImplementedError() + pass + @abc.abstractmethod def get_networks(self, filters=None, fields=None, sorts=None, limit=None, marker=None, page_reverse=False): - raise NotImplementedError() + pass + @abc.abstractmethod def delete_network(self, id_): - raise NotImplementedError() + pass class BaseTestApi(sub_base.SubBaseTestCase):