From 7ef7d732f8f80e46a3a9e0fa7f2f9a8f973cec60 Mon Sep 17 00:00:00 2001 From: Philip Jenvey Date: Fri, 28 Jul 2017 14:09:33 -0700 Subject: [PATCH] refactor: AutopushSettings -> AutopushConfig --- autopush/base.py | 4 ++-- autopush/db.py | 4 ++-- autopush/diagnostic_cli.py | 4 ++-- autopush/exceptions.py | 2 +- autopush/http.py | 14 +++++++------- autopush/main.py | 10 +++++----- autopush/metrics.py | 4 ++-- autopush/router/__init__.py | 4 ++-- autopush/router/apnsrouter.py | 2 +- autopush/settings.py | 4 ++-- autopush/tests/test_diagnostic_cli.py | 2 +- autopush/tests/test_endpoint.py | 10 +++++----- autopush/tests/test_health.py | 6 +++--- autopush/tests/test_integration.py | 8 ++++---- autopush/tests/test_log_check.py | 4 ++-- autopush/tests/test_main.py | 22 +++++++++++----------- autopush/tests/test_router.py | 18 +++++++++--------- autopush/tests/test_web_base.py | 4 ++-- autopush/tests/test_web_validation.py | 4 ++-- autopush/tests/test_web_webpush.py | 4 ++-- autopush/tests/test_websocket.py | 8 ++++---- autopush/websocket.py | 8 ++++---- docs/api/settings.rst | 2 +- docs/architecture.rst | 2 +- 24 files changed, 77 insertions(+), 77 deletions(-) diff --git a/autopush/base.py b/autopush/base.py index 21b6ce67..0b390ced 100644 --- a/autopush/base.py +++ b/autopush/base.py @@ -9,7 +9,7 @@ if TYPE_CHECKING: # pragma: nocover from autopush.db import DatabaseManager # noqa from autopush.metrics import IMetrics # noqa - from autopush.settings import AutopushSettings # noqa + from autopush.settings import AutopushConfig # noqa class BaseHandler(cyclone.web.RequestHandler): @@ -23,7 +23,7 @@ def initialize(self): @property def ap_settings(self): - # type: () -> AutopushSettings + # type: () -> AutopushConfig return self.application.ap_settings @property diff --git a/autopush/db.py b/autopush/db.py index 0f7089a7..71255215 100644 --- a/autopush/db.py +++ b/autopush/db.py @@ -81,7 +81,7 @@ ) if TYPE_CHECKING: # pragma: nocover - from autopush.settings import AutopushSettings, DDBTableConfig # noqa + from autopush.settings import AutopushConfig, DDBTableConfig # noqa # Typing @@ -886,7 +886,7 @@ def __attrs_post_init__(self): @classmethod def from_settings(cls, settings, **kwargs): - # type: (AutopushSettings, **Any) -> DatabaseManager + # type: (AutopushConfig, **Any) -> DatabaseManager """Create a DatabaseManager from the given settings""" metrics = autopush.metrics.from_settings(settings) return cls( diff --git a/autopush/diagnostic_cli.py b/autopush/diagnostic_cli.py index 1910788e..c402ba1d 100644 --- a/autopush/diagnostic_cli.py +++ b/autopush/diagnostic_cli.py @@ -9,7 +9,7 @@ from autopush.db import DatabaseManager from autopush.main import AutopushMultiService from autopush.main_argparse import add_shared_args -from autopush.settings import AutopushSettings +from autopush.settings import AutopushConfig PUSH_RE = re.compile(r"push/(?:(?Pv\d+)/)?(?P[^/]+)") @@ -20,7 +20,7 @@ class EndpointDiagnosticCLI(object): def __init__(self, sysargs, use_files=True): ns = self._load_args(sysargs, use_files) - self._settings = settings = AutopushSettings.from_argparse(ns) + self._settings = settings = AutopushConfig.from_argparse(ns) settings.statsd_host = None self.db = DatabaseManager.from_settings(settings) self.db.setup(settings.preflight_uaid) diff --git a/autopush/exceptions.py b/autopush/exceptions.py index 7f3cbc11..68388493 100644 --- a/autopush/exceptions.py +++ b/autopush/exceptions.py @@ -63,4 +63,4 @@ class LogCheckError(Exception): class InvalidSettings(Exception): - """Error in initialization of AutopushSettings""" + """Error in initialization of AutopushConfig""" diff --git a/autopush/http.py b/autopush/http.py index ce690a82..d4f36b14 100644 --- a/autopush/http.py +++ b/autopush/http.py @@ -21,7 +21,7 @@ from autopush.db import DatabaseManager from autopush.router import routers_from_settings from autopush.router.interface import IRouter # noqa -from autopush.settings import AutopushSettings # noqa +from autopush.settings import AutopushConfig # noqa from autopush.ssl import AutopushSSLContextFactory # noqa from autopush.web.health import ( HealthHandler, @@ -65,7 +65,7 @@ class BaseHTTPFactory(cyclone.web.Application): ) def __init__(self, - ap_settings, # type: AutopushSettings + ap_settings, # type: AutopushConfig db, # type: DatabaseManager handlers=None, # type: APHandlers log_function=skip_request_logging, # type: CycloneLogger @@ -95,7 +95,7 @@ def _hostname(self): @classmethod def for_handler(cls, handler_cls, # Type[BaseHTTPFactory] - ap_settings, # type: AutopushSettings + ap_settings, # type: AutopushConfig db=None, # type: Optional[DatabaseManager] **kwargs): # type: (...) -> BaseHTTPFactory @@ -125,7 +125,7 @@ def for_handler(cls, @classmethod def _for_handler(cls, ap_settings, **kwargs): - # type: (AutopushSettings, **Any) -> BaseHTTPFactory + # type: (AutopushConfig, **Any) -> BaseHTTPFactory """Create an instance w/ default kwargs for for_handler""" raise NotImplementedError # pragma: nocover @@ -153,7 +153,7 @@ class EndpointHTTPFactory(BaseHTTPFactory): protocol = LimitedHTTPConnection def __init__(self, - ap_settings, # type: AutopushSettings + ap_settings, # type: AutopushConfig db, # type: DatabaseManager routers, # type: Dict[str, IRouter] **kwargs): @@ -197,7 +197,7 @@ class InternalRouterHTTPFactory(BaseHTTPFactory): ) def __init__(self, - ap_settings, # type: AutopushSettings + ap_settings, # type: AutopushConfig db, # type: DatabaseManager clients, # type: Dict[str, PushServerProtocol] **kwargs): @@ -239,7 +239,7 @@ class QuietClientFactory(_HTTP11ClientFactory): def agent_from_settings(settings): - # type: (AutopushSettings) -> Agent + # type: (AutopushConfig) -> Agent """Create a twisted.web.client Agent from settings""" # Use a persistent connection pool for HTTP requests. pool = HTTPConnectionPool(reactor) diff --git a/autopush/main.py b/autopush/main.py index 0effaa55..56b5bc42 100644 --- a/autopush/main.py +++ b/autopush/main.py @@ -34,7 +34,7 @@ from autopush.logging import PushLogger from autopush.main_argparse import parse_connection, parse_endpoint from autopush.router import routers_from_settings -from autopush.settings import AutopushSettings +from autopush.settings import AutopushConfig from autopush.websocket import ( ConnectionWSSite, PushServerFactory, @@ -59,7 +59,7 @@ class AutopushMultiService(MultiService): THREAD_POOL_SIZE = 50 def __init__(self, settings): - # type: (AutopushSettings) -> None + # type: (AutopushConfig) -> None super(AutopushMultiService, self).__init__() self.settings = settings self.db = DatabaseManager.from_settings(settings) @@ -112,7 +112,7 @@ def _from_argparse(cls, ns, **kwargs): """Create an instance from argparse/additional kwargs""" # Add some entropy to prevent potential conflicts. postfix = os.urandom(4).encode('hex').ljust(8, '0') - settings = AutopushSettings.from_argparse( + settings = AutopushConfig.from_argparse( ns, debug=ns.debug, preflight_uaid="deadbeef000000000deadbeef" + postfix, @@ -165,7 +165,7 @@ class EndpointApplication(AutopushMultiService): endpoint_factory = EndpointHTTPFactory def __init__(self, settings): - # type: (AutopushSettings) -> None + # type: (AutopushConfig) -> None super(EndpointApplication, self).__init__(settings) self.routers = routers_from_settings(settings, self.db, self.agent) @@ -231,7 +231,7 @@ class ConnectionApplication(AutopushMultiService): websocket_site_factory = ConnectionWSSite def __init__(self, settings): - # type: (AutopushSettings) -> None + # type: (AutopushConfig) -> None super(ConnectionApplication, self).__init__(settings) self.clients = {} # type: Dict[str, PushServerProtocol] diff --git a/autopush/metrics.py b/autopush/metrics.py index c41f004d..d94ade42 100644 --- a/autopush/metrics.py +++ b/autopush/metrics.py @@ -11,7 +11,7 @@ from autopush.utils import get_ec2_instance_id if TYPE_CHECKING: # pragma: nocover - from autopush.settings import AutopushSettings # noqa + from autopush.settings import AutopushConfig # noqa class IMetrics(object): @@ -115,7 +115,7 @@ def timing(self, name, duration, **kwargs): def from_settings(settings): - # type: (AutopushSettings) -> IMetrics + # type: (AutopushConfig) -> IMetrics """Create an IMetrics from the given settings""" if settings.datadog_api_key: return DatadogMetrics( diff --git a/autopush/router/__init__.py b/autopush/router/__init__.py index 4d1847c3..07c31420 100644 --- a/autopush/router/__init__.py +++ b/autopush/router/__init__.py @@ -15,14 +15,14 @@ from autopush.router.simple import SimpleRouter from autopush.router.webpush import WebPushRouter from autopush.router.fcm import FCMRouter -from autopush.settings import AutopushSettings # noqa +from autopush.settings import AutopushConfig # noqa __all__ = ["APNSRouter", "FCMRouter", "GCMRouter", "WebPushRouter", "SimpleRouter"] def routers_from_settings(settings, db, agent): - # type: (AutopushSettings, DatabaseManager, Agent) -> Dict[str, IRouter] + # type: (AutopushConfig, DatabaseManager, Agent) -> Dict[str, IRouter] """Create a dict of IRouters for the given settings""" router_conf = settings.router_conf routers = dict( diff --git a/autopush/router/apnsrouter.py b/autopush/router/apnsrouter.py index 751a10bd..b2029ef0 100644 --- a/autopush/router/apnsrouter.py +++ b/autopush/router/apnsrouter.py @@ -53,7 +53,7 @@ def __init__(self, ap_settings, router_conf, metrics, """Create a new APNS router and connect to APNS :param ap_settings: Configuration settings - :type ap_settings: autopush.settings.AutopushSettings + :type ap_settings: autopush.settings.AutopushConfig :param router_conf: Router specific configuration :type router_conf: dict :param load_connections: (used for testing) diff --git a/autopush/settings.py b/autopush/settings.py index 241b8284..73acd9f3 100644 --- a/autopush/settings.py +++ b/autopush/settings.py @@ -92,7 +92,7 @@ class DDBTableConfig(object): @attrs -class AutopushSettings(object): +class AutopushConfig(object): """Main Autopush Settings Object""" debug = attrib(default=False) # type: bool @@ -216,7 +216,7 @@ def enable_tls_auth(self): @classmethod def from_argparse(cls, ns, **kwargs): - # type: (Namespace, **Any) -> AutopushSettings + # type: (Namespace, **Any) -> AutopushConfig """Create an instance from argparse/additional kwargs""" router_conf = {} if ns.key_hash: diff --git a/autopush/tests/test_diagnostic_cli.py b/autopush/tests/test_diagnostic_cli.py index b16f340d..1eb4c75a 100644 --- a/autopush/tests/test_diagnostic_cli.py +++ b/autopush/tests/test_diagnostic_cli.py @@ -28,7 +28,7 @@ def test_bad_endpoint(self): returncode = cli.run() ok_(returncode not in (None, 0)) - @patch("autopush.diagnostic_cli.AutopushSettings") + @patch("autopush.diagnostic_cli.AutopushConfig") @patch("autopush.diagnostic_cli.DatabaseManager.from_settings") def test_successfull_lookup(self, mock_db_cstr, mock_settings_class): from autopush.diagnostic_cli import run_endpoint_diagnostic_cli diff --git a/autopush/tests/test_endpoint.py b/autopush/tests/test_endpoint.py index c6cacdb6..d4c6398b 100644 --- a/autopush/tests/test_endpoint.py +++ b/autopush/tests/test_endpoint.py @@ -21,7 +21,7 @@ from autopush.metrics import SinkMetrics from autopush.router import routers_from_settings from autopush.router.interface import IRouter -from autopush.settings import AutopushSettings +from autopush.settings import AutopushConfig from autopush.tests.client import Client from autopush.tests.test_db import make_webpush_notification from autopush.tests.support import test_db @@ -47,7 +47,7 @@ def write(self, data): class MessageTestCase(unittest.TestCase): def setUp(self): twisted.internet.base.DelayedCall.debug = True - settings = AutopushSettings( + settings = AutopushConfig( hostname="localhost", statsd_host=None, crypto_key='AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=', @@ -135,7 +135,7 @@ class RegistrationTestCase(unittest.TestCase): def setUp(self): twisted.internet.base.DelayedCall.debug = True - settings = AutopushSettings( + settings = AutopushConfig( hostname="localhost", statsd_host=None, bear_hash_key='AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB=', @@ -208,12 +208,12 @@ def test_init_info(self): def test_settings_crypto_key(self): fake = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' - settings = AutopushSettings(crypto_key=fake) + settings = AutopushConfig(crypto_key=fake) eq_(settings.fernet._fernets[0]._encryption_key, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') fake2 = 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=' - settings = AutopushSettings(crypto_key=[fake, fake2]) + settings = AutopushConfig(crypto_key=[fake, fake2]) eq_(settings.fernet._fernets[0]._encryption_key, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') eq_(settings.fernet._fernets[1]._encryption_key, diff --git a/autopush/tests/test_health.py b/autopush/tests/test_health.py index bfd3e97b..ed6ec066 100644 --- a/autopush/tests/test_health.py +++ b/autopush/tests/test_health.py @@ -13,7 +13,7 @@ from autopush.exceptions import MissingTableException from autopush.http import EndpointHTTPFactory from autopush.logging import begin_or_register -from autopush.settings import AutopushSettings +from autopush.settings import AutopushConfig from autopush.tests.client import Client from autopush.tests.support import TestingLogObserver from autopush.web.health import HealthHandler, StatusHandler @@ -24,7 +24,7 @@ def setUp(self): self.timeout = 0.5 twisted.internet.base.DelayedCall.debug = True - settings = AutopushSettings( + settings = AutopushConfig( hostname="localhost", statsd_host=None, ) @@ -124,7 +124,7 @@ def _assert_reply(self, reply, exception=None): class StatusTestCase(unittest.TestCase): def setUp(self): twisted.internet.base.DelayedCall.debug = True - settings = AutopushSettings( + settings = AutopushConfig( hostname="localhost", statsd_host=None, ) diff --git a/autopush/tests/test_integration.py b/autopush/tests/test_integration.py index ae1724e5..c06cacae 100644 --- a/autopush/tests/test_integration.py +++ b/autopush/tests/test_integration.py @@ -40,7 +40,7 @@ ) from autopush.logging import begin_or_register from autopush.main import ConnectionApplication, EndpointApplication -from autopush.settings import AutopushSettings +from autopush.settings import AutopushConfig from autopush.utils import base64url_encode from autopush.metrics import SinkMetrics, DatadogMetrics from autopush.tests.support import TestingLogObserver @@ -295,7 +295,7 @@ def wait_for(self, func): class IntegrationBase(unittest.TestCase): track_objects = True - track_objects_excludes = [AutopushSettings, PushServerFactory] + track_objects_excludes = [AutopushConfig, PushServerFactory] endpoint_port = 9020 @@ -332,11 +332,11 @@ def setUp(self): self.addCleanup(globalLogPublisher.removeObserver, self.logs) crypto_key = Fernet.generate_key() - ep_settings = AutopushSettings( + ep_settings = AutopushConfig( crypto_key=crypto_key, **self.endpoint_kwargs() ) - conn_settings = AutopushSettings( + conn_settings = AutopushConfig( crypto_key=crypto_key, **self.conn_kwargs() ) diff --git a/autopush/tests/test_log_check.py b/autopush/tests/test_log_check.py index ba9183a6..81145b74 100644 --- a/autopush/tests/test_log_check.py +++ b/autopush/tests/test_log_check.py @@ -8,7 +8,7 @@ from autopush.http import EndpointHTTPFactory from autopush.logging import begin_or_register -from autopush.settings import AutopushSettings +from autopush.settings import AutopushConfig from autopush.tests.client import Client from autopush.tests.support import TestingLogObserver from autopush.web.log_check import LogCheckHandler @@ -19,7 +19,7 @@ class LogCheckTestCase(unittest.TestCase): def setUp(self): twisted.internet.base.DelayedCall.debug = True - settings = AutopushSettings( + settings = AutopushConfig( hostname="localhost", statsd_host=None, ) diff --git a/autopush/tests/test_main.py b/autopush/tests/test_main.py index 2fb72a17..ab6eb724 100644 --- a/autopush/tests/test_main.py +++ b/autopush/tests/test_main.py @@ -21,7 +21,7 @@ ConnectionApplication, EndpointApplication, ) -from autopush.settings import AutopushSettings +from autopush.settings import AutopushConfig from autopush.tests.support import test_db from autopush.utils import resolve_ip @@ -32,7 +32,7 @@ class SettingsTestCase(unittest.TestCase): def test_resolve_host(self): ip = resolve_ip("example.com") - settings = AutopushSettings( + settings = AutopushConfig( hostname="example.com", resolve_hostname=True) eq_(settings.hostname, ip) @@ -62,7 +62,7 @@ def test_new_month(self): class SettingsAsyncTestCase(trialtest.TestCase): def test_update_rotating_tables(self): from autopush.db import get_month - settings = AutopushSettings( + settings = AutopushConfig( hostname="example.com", resolve_hostname=True) db = DatabaseManager.from_settings(settings) db.create_initial_message_tables() @@ -117,7 +117,7 @@ def test_update_rotating_tables_month_end(self): month=next_month, day=1) - settings = AutopushSettings( + settings = AutopushConfig( hostname="example.com", resolve_hostname=True) db = DatabaseManager.from_settings(settings) db._tomorrow = Mock(return_value=tomorrow) @@ -145,7 +145,7 @@ def check_tables(result): def test_update_not_needed(self): from autopush.db import get_month - settings = AutopushSettings( + settings = AutopushConfig( hostname="google.com", resolve_hostname=True) db = DatabaseManager.from_settings(settings) db.create_initial_message_tables() @@ -330,7 +330,7 @@ def test_memusage(self): @patch('hyper.tls', spec=hyper.tls) def test_client_certs_parse(self, mock): - settings = AutopushSettings.from_argparse(self.TestArg) + settings = AutopushConfig.from_argparse(self.TestArg) eq_(settings.client_certs["1A:"*31 + "F9"], 'partner1') eq_(settings.client_certs["2B:"*31 + "E8"], 'partner2') eq_(settings.client_certs["3C:"*31 + "D7"], 'partner2') @@ -356,7 +356,7 @@ def test_bad_client_certs(self): spec=hyper.HTTP20Connection) @patch('hyper.tls', spec=hyper.tls) def test_settings(self, *args): - settings = AutopushSettings.from_argparse(self.TestArg) + settings = AutopushConfig.from_argparse(self.TestArg) app = EndpointApplication(settings) # verify that the hostname is what we said. eq_(settings.hostname, self.TestArg.hostname) @@ -369,7 +369,7 @@ def test_bad_senders(self): old_list = self.TestArg.senderid_list self.TestArg.senderid_list = "{}" with assert_raises(InvalidSettings): - AutopushSettings.from_argparse(self.TestArg) + AutopushConfig.from_argparse(self.TestArg) self.TestArg.senderid_list = old_list def test_bad_fcm_senders(self): @@ -377,11 +377,11 @@ def test_bad_fcm_senders(self): old_senderid = self.TestArg.fcm_senderid self.TestArg.fcm_auth = "" with assert_raises(InvalidSettings): - AutopushSettings.from_argparse(self.TestArg) + AutopushConfig.from_argparse(self.TestArg) self.TestArg.fcm_auth = old_auth self.TestArg.fcm_senderid = "" with assert_raises(InvalidSettings): - AutopushSettings.from_argparse(self.TestArg) + AutopushConfig.from_argparse(self.TestArg) self.TestArg.fcm_senderid = old_senderid def test_gcm_start(self): @@ -400,5 +400,5 @@ class MockReply: request_mock.return_value = MockReply self.TestArg.no_aws = False - settings = AutopushSettings.from_argparse(self.TestArg) + settings = AutopushConfig.from_argparse(self.TestArg) eq_(settings.ami_id, "ami_123") diff --git a/autopush/tests/test_router.py b/autopush/tests/test_router.py index b049d973..64e8caac 100644 --- a/autopush/tests/test_router.py +++ b/autopush/tests/test_router.py @@ -34,7 +34,7 @@ FCMRouter, ) from autopush.router.interface import RouterResponse, IRouter -from autopush.settings import AutopushSettings +from autopush.settings import AutopushConfig from autopush.tests import MockAssist from autopush.tests.support import test_db from autopush.web.base import Notification @@ -74,7 +74,7 @@ def _waitfor(self, func): @patch('hyper.tls', spec=hyper.tls) def setUp(self, mt, mc): from twisted.logger import Logger - settings = AutopushSettings( + settings = AutopushConfig( hostname="localhost", statsd_host=None, ) @@ -295,7 +295,7 @@ class GCMRouterTestCase(unittest.TestCase): @patch("gcmclient.gcm.GCM", spec=gcmclient.gcm.GCM) def setUp(self, fgcm): - settings = AutopushSettings( + settings = AutopushConfig( hostname="localhost", statsd_host=None, ) @@ -339,7 +339,7 @@ def _check_error_call(self, exc, code, response=None): self.flushLoggedErrors() def test_init(self): - settings = AutopushSettings( + settings = AutopushConfig( hostname="localhost", statsd_host=None, ) @@ -368,7 +368,7 @@ def test_register_bad(self): @patch("gcmclient.GCM") def test_gcmclient_fail(self, fgcm): fgcm.side_effect = Exception - settings = AutopushSettings( + settings = AutopushConfig( hostname="localhost", statsd_host=None, ) @@ -627,7 +627,7 @@ class FCMRouterTestCase(unittest.TestCase): @patch("pyfcm.FCMNotification", spec=pyfcm.FCMNotification) def setUp(self, ffcm): - settings = AutopushSettings( + settings = AutopushConfig( hostname="localhost", statsd_host=None, ) @@ -671,7 +671,7 @@ def _check_error_call(self, exc, code): @patch("pyfcm.FCMNotification", spec=pyfcm.FCMNotification) def test_init(self, ffcm): - settings = AutopushSettings( + settings = AutopushConfig( hostname="localhost", statsd_host=None, ) @@ -911,7 +911,7 @@ def test_register_invalid_token(self): class SimplePushRouterTestCase(unittest.TestCase): def setUp(self): from twisted.logger import Logger - settings = AutopushSettings( + settings = AutopushConfig( hostname="localhost", statsd_host=None, ) @@ -1149,7 +1149,7 @@ def test_amend(self): class WebPushRouterTestCase(unittest.TestCase): def setUp(self): - settings = AutopushSettings( + settings = AutopushConfig( hostname="localhost", statsd_host=None, ) diff --git a/autopush/tests/test_web_base.py b/autopush/tests/test_web_base.py index 76c6613d..e071774a 100644 --- a/autopush/tests/test_web_base.py +++ b/autopush/tests/test_web_base.py @@ -12,7 +12,7 @@ from autopush.db import ProvisionedThroughputExceededException from autopush.http import EndpointHTTPFactory from autopush.exceptions import InvalidRequest -from autopush.settings import AutopushSettings +from autopush.settings import AutopushConfig from autopush.metrics import SinkMetrics from autopush.tests.support import test_db @@ -36,7 +36,7 @@ class TestBase(unittest.TestCase): def setUp(self): from autopush.web.base import BaseWebHandler - settings = AutopushSettings( + settings = AutopushConfig( hostname="localhost", statsd_host=None, ) diff --git a/autopush/tests/test_web_validation.py b/autopush/tests/test_web_validation.py index 3b347c1d..c17e509f 100644 --- a/autopush/tests/test_web_validation.py +++ b/autopush/tests/test_web_validation.py @@ -774,8 +774,8 @@ def test_old_current_month(self): class TestWebPushRequestSchemaUsingVapid(unittest.TestCase): def _make_fut(self): from autopush.web.webpush import WebPushRequestSchema - from autopush.settings import AutopushSettings - settings = AutopushSettings( + from autopush.settings import AutopushConfig + settings = AutopushConfig( hostname="localhost", statsd_host=None, ) diff --git a/autopush/tests/test_web_webpush.py b/autopush/tests/test_web_webpush.py index f47f48e9..8217f94b 100644 --- a/autopush/tests/test_web_webpush.py +++ b/autopush/tests/test_web_webpush.py @@ -10,7 +10,7 @@ from autopush.db import Message from autopush.http import EndpointHTTPFactory from autopush.router.interface import IRouter, RouterResponse -from autopush.settings import AutopushSettings +from autopush.settings import AutopushConfig from autopush.tests.client import Client from autopush.tests.support import test_db @@ -23,7 +23,7 @@ class TestWebpushHandler(unittest.TestCase): def setUp(self): from autopush.web.webpush import WebPushHandler - self.ap_settings = settings = AutopushSettings( + self.ap_settings = settings = AutopushConfig( hostname="localhost", statsd_host=None, use_cryptography=True, diff --git a/autopush/tests/test_websocket.py b/autopush/tests/test_websocket.py index 9e2b017c..6e4e58e2 100644 --- a/autopush/tests/test_websocket.py +++ b/autopush/tests/test_websocket.py @@ -29,7 +29,7 @@ from autopush.db import DatabaseManager from autopush.http import InternalRouterHTTPFactory from autopush.metrics import SinkMetrics -from autopush.settings import AutopushSettings +from autopush.settings import AutopushConfig from autopush.tests import MockAssist from autopush.utils import WebPushNotification from autopush.tests.client import Client @@ -100,7 +100,7 @@ def setUp(self): from twisted.logger import Logger twisted.internet.base.DelayedCall.debug = True - self.ap_settings = settings = AutopushSettings( + self.ap_settings = settings = AutopushConfig( hostname="localhost", port=8080, statsd_host=None, @@ -1915,7 +1915,7 @@ class RouterHandlerTestCase(unittest.TestCase): def setUp(self): twisted.internet.base.DelayedCall.debug = True - self.ap_settings = settings = AutopushSettings( + self.ap_settings = settings = AutopushConfig( hostname="localhost", statsd_host=None, ) @@ -1956,7 +1956,7 @@ class NotificationHandlerTestCase(unittest.TestCase): def setUp(self): twisted.internet.base.DelayedCall.debug = True - self.ap_settings = settings = AutopushSettings( + self.ap_settings = settings = AutopushConfig( hostname="localhost", statsd_host=None, ) diff --git a/autopush/websocket.py b/autopush/websocket.py index 724b3202..01ee2f3b 100644 --- a/autopush/websocket.py +++ b/autopush/websocket.py @@ -95,7 +95,7 @@ from autopush.noseplugin import track_object from autopush.protocol import IgnoreBody from autopush.metrics import IMetrics, make_tags # noqa -from autopush.settings import AutopushSettings # noqa +from autopush.settings import AutopushConfig # noqa from autopush.ssl import AutopushSSLContextFactory # noqa from autopush.types import JSONDict # noqa from autopush.utils import ( @@ -332,7 +332,7 @@ class PushServerProtocol(WebSocketServerProtocol, policies.TimeoutMixin): @property def ap_settings(self): - # type: () -> AutopushSettings + # type: () -> AutopushConfig return self.factory.ap_settings @property @@ -1525,7 +1525,7 @@ class PushServerFactory(WebSocketServerFactory): protocol = PushServerProtocol def __init__(self, ap_settings, db, agent, clients): - # type: (AutopushSettings, DatabaseManager, Agent, Dict) -> None + # type: (AutopushConfig, DatabaseManager, Agent, Dict) -> None WebSocketServerFactory.__init__(self, ap_settings.ws_url) self.ap_settings = ap_settings self.db = db @@ -1615,7 +1615,7 @@ class ConnectionWSSite(Site): """The Websocket Site""" def __init__(self, ap_settings, ws_factory): - # type: (AutopushSettings, PushServerFactory) -> None + # type: (AutopushConfig, PushServerFactory) -> None self.ap_settings = ap_settings self.noisy = ap_settings.debug diff --git a/docs/api/settings.rst b/docs/api/settings.rst index e78461da..cce1520b 100644 --- a/docs/api/settings.rst +++ b/docs/api/settings.rst @@ -5,7 +5,7 @@ .. automodule:: autopush.settings -.. autoclass:: AutopushSettings +.. autoclass:: AutopushConfig :members: :special-members: __init__ :member-order: bysource diff --git a/docs/architecture.rst b/docs/architecture.rst index e6ca03df..8797843a 100644 --- a/docs/architecture.rst +++ b/docs/architecture.rst @@ -49,7 +49,7 @@ The HTTP endpoint URL's generated by the connection nodes contain encrypted information, the :term:`UAID` and :term:`Subscription` to send the message to. This means that they both must have the same ``CRYPTO_KEY`` supplied to each. -See :meth:`~autopush.settings.AutopushSettings.make_endpoint` for the endpoint +See :meth:`~autopush.settings.AutopushConfig.make_endpoint` for the endpoint URL generator. If you are only running Autopush locally, you can skip to :ref:`running` as