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
This commit is contained in:
parent
5e90e6ea60
commit
37aec6d507
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user