Make it clear that client do not use __init__

The clients never get passed useful values to their `__init__` methods.
Rather the real values are passed through later using the `init_app`
method.

So it should be an error if the client is relying on the values that
get passed to it’s init method. Easiest way to ensure this is by making
the `__init__` method not expect any arguments and passing fake values
to the `Super` call.
This commit is contained in:
Chris Hill-Scott
2016-09-12 12:14:57 +01:00
parent fa5e5475e9
commit 5fda35c89d
11 changed files with 21 additions and 47 deletions

View File

@@ -9,10 +9,8 @@ KEY_TYPE_TEST = 'test'
class ApiKeyApiClient(BaseAPIClient):
def __init__(self, base_url=None, service_id=None, api_key=None):
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
service_id=service_id or 'service_id',
api_key=api_key or 'api_key')
def __init__(self):
super(self.__class__, self).__init__("a", "b", "c")
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']

View File

@@ -2,10 +2,8 @@ from notifications_python_client.base import BaseAPIClient
class EventsApiClient(BaseAPIClient):
def __init__(self, base_url=None, service_id=None, api_key=None):
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
service_id=service_id or 'service_id',
api_key=api_key or 'api_key')
def __init__(self):
super(self.__class__, self).__init__("a", "b", "c")
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']

View File

@@ -6,10 +6,8 @@ from app.notify_client.models import InvitedUser
class InviteApiClient(BaseAPIClient):
def __init__(self, base_url=None, service_id=None, api_key=None):
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
service_id=service_id or 'service_id',
api_key=api_key or 'api_key')
def __init__(self):
super(self.__class__, self).__init__("a", "b", "c")
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']

View File

@@ -5,10 +5,8 @@ from app.notify_client import _attach_current_user
class JobApiClient(BaseAPIClient):
def __init__(self, base_url=None, service_id=None, api_key=None):
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
service_id=service_id or 'service_id',
api_key=api_key or 'api_key')
def __init__(self):
super(self.__class__, self).__init__("a", "b", "c")
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']

View File

@@ -2,10 +2,8 @@ from notifications_python_client.base import BaseAPIClient
class NotificationApiClient(BaseAPIClient):
def __init__(self, base_url=None, service_id=None, api_key=None):
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
service_id=service_id or 'service_id',
api_key=api_key or 'api_key')
def __init__(self):
super(self.__class__, self).__init__("a", "b", "c")
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']

View File

@@ -3,12 +3,8 @@ from notifications_python_client.base import BaseAPIClient
class OrganisationsClient(BaseAPIClient):
def __init__(self, base_url=None, service_id=None, api_key=None):
super(self.__class__, self).__init__(
base_url=base_url or 'base_url',
service_id=service_id or 'service_id',
api_key=api_key or 'api_key'
)
def __init__(self):
super(self.__class__, self).__init__("a", "b", "c")
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']

View File

@@ -3,12 +3,8 @@ from app.notify_client import _attach_current_user
class ProviderClient(BaseAPIClient):
def __init__(self, base_url=None, service_id=None, api_key=None):
super(self.__class__, self).__init__(
base_url=base_url or 'base_url',
service_id=service_id or 'service_id',
api_key=api_key or 'api_key'
)
def __init__(self):
super(self.__class__, self).__init__("a", "b", "c")
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']

View File

@@ -9,9 +9,7 @@ class ServiceAPIClient(NotificationsAPIClient):
# Fudge assert in the super __init__ so
# we can set those variables later.
def __init__(self):
super(ServiceAPIClient, self).__init__("api_url",
"client",
"api_key")
super(self.__class__, self).__init__("a", "b", "c")
def init_app(self, application):
self.base_url = application.config['API_HOST_NAME']

View File

@@ -2,10 +2,8 @@ from notifications_python_client.base import BaseAPIClient
class StatusApiClient(BaseAPIClient):
def __init__(self, base_url=None, service_id=None, api_key=None):
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
service_id=service_id or 'service_id',
api_key=api_key or 'api_key')
def __init__(self):
super(self.__class__, self).__init__("a", "b", "c")
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']

View File

@@ -2,10 +2,8 @@ from notifications_python_client.base import BaseAPIClient
class TemplateStatisticsApiClient(BaseAPIClient):
def __init__(self, base_url=None, service_id=None, api_key=None):
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
service_id=service_id or 'service_id',
api_key=api_key or 'api_key')
def __init__(self):
super(self.__class__, self).__init__("a", "b", "c")
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']

View File

@@ -5,10 +5,8 @@ from app.notify_client.models import User
class UserApiClient(BaseAPIClient):
def __init__(self, base_url=None, service_id=None, api_key=None):
super(self.__class__, self).__init__(base_url=base_url or 'base_url',
service_id=service_id or 'service_id',
api_key=api_key or 'api_key')
def __init__(self):
super(self.__class__, self).__init__("a", "b", "c")
def init_app(self, app):
self.base_url = app.config['API_HOST_NAME']