From 4707e57ee538f9e11e720030e4cba9e69d67a7a3 Mon Sep 17 00:00:00 2001 From: Philip Jenvey Date: Fri, 28 Jul 2017 14:15:22 -0700 Subject: [PATCH] refactor: autopush.settings -> autopush.config --- autopush/base.py | 2 +- autopush/{settings.py => config.py} | 2 +- autopush/db.py | 2 +- autopush/diagnostic_cli.py | 2 +- autopush/http.py | 2 +- autopush/main.py | 4 ++-- autopush/metrics.py | 2 +- autopush/router/__init__.py | 2 +- autopush/router/apnsrouter.py | 2 +- autopush/tests/support.py | 2 +- autopush/tests/test_endpoint.py | 2 +- autopush/tests/test_health.py | 2 +- autopush/tests/test_integration.py | 2 +- autopush/tests/test_log_check.py | 2 +- autopush/tests/test_main.py | 2 +- autopush/tests/test_router.py | 2 +- autopush/tests/test_web_base.py | 2 +- autopush/tests/test_web_validation.py | 2 +- autopush/tests/test_web_webpush.py | 2 +- autopush/tests/test_websocket.py | 2 +- autopush/websocket.py | 2 +- 21 files changed, 22 insertions(+), 22 deletions(-) rename autopush/{settings.py => config.py} (99%) diff --git a/autopush/base.py b/autopush/base.py index 0b390ced..d21f81c7 100644 --- a/autopush/base.py +++ b/autopush/base.py @@ -7,9 +7,9 @@ from twisted.python import failure if TYPE_CHECKING: # pragma: nocover + from autopush.config import AutopushConfig # noqa from autopush.db import DatabaseManager # noqa from autopush.metrics import IMetrics # noqa - from autopush.settings import AutopushConfig # noqa class BaseHandler(cyclone.web.RequestHandler): diff --git a/autopush/settings.py b/autopush/config.py similarity index 99% rename from autopush/settings.py rename to autopush/config.py index 73acd9f3..a9480f8d 100644 --- a/autopush/settings.py +++ b/autopush/config.py @@ -1,4 +1,4 @@ -"""Autopush Settings Object and Setup""" +"""Autopush Config Object and Setup""" import json import socket from argparse import Namespace # noqa diff --git a/autopush/db.py b/autopush/db.py index 71255215..4afaccab 100644 --- a/autopush/db.py +++ b/autopush/db.py @@ -81,7 +81,7 @@ ) if TYPE_CHECKING: # pragma: nocover - from autopush.settings import AutopushConfig, DDBTableConfig # noqa + from autopush.config import AutopushConfig, DDBTableConfig # noqa # Typing diff --git a/autopush/diagnostic_cli.py b/autopush/diagnostic_cli.py index c402ba1d..148bb057 100644 --- a/autopush/diagnostic_cli.py +++ b/autopush/diagnostic_cli.py @@ -6,10 +6,10 @@ import configargparse from twisted.logger import Logger +from autopush.config import AutopushConfig from autopush.db import DatabaseManager from autopush.main import AutopushMultiService from autopush.main_argparse import add_shared_args -from autopush.settings import AutopushConfig PUSH_RE = re.compile(r"push/(?:(?Pv\d+)/)?(?P[^/]+)") diff --git a/autopush/http.py b/autopush/http.py index d4f36b14..0ae9af0d 100644 --- a/autopush/http.py +++ b/autopush/http.py @@ -18,10 +18,10 @@ ) from autopush.base import BaseHandler +from autopush.config import AutopushConfig # noqa from autopush.db import DatabaseManager from autopush.router import routers_from_settings from autopush.router.interface import IRouter # noqa -from autopush.settings import AutopushConfig # noqa from autopush.ssl import AutopushSSLContextFactory # noqa from autopush.web.health import ( HealthHandler, diff --git a/autopush/main.py b/autopush/main.py index 56b5bc42..759cc36a 100644 --- a/autopush/main.py +++ b/autopush/main.py @@ -28,13 +28,13 @@ ) import autopush.utils as utils import autopush.logging as logging -from autopush.exceptions import InvalidSettings +from autopush.config import AutopushConfig from autopush.db import DatabaseManager +from autopush.exceptions import InvalidSettings from autopush.haproxy import HAProxyServerEndpoint 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 AutopushConfig from autopush.websocket import ( ConnectionWSSite, PushServerFactory, diff --git a/autopush/metrics.py b/autopush/metrics.py index d94ade42..45316318 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 AutopushConfig # noqa + from autopush.config import AutopushConfig # noqa class IMetrics(object): diff --git a/autopush/router/__init__.py b/autopush/router/__init__.py index 07c31420..ea33e83f 100644 --- a/autopush/router/__init__.py +++ b/autopush/router/__init__.py @@ -8,6 +8,7 @@ from twisted.web.client import Agent # noqa +from autopush.config import AutopushConfig # noqa from autopush.db import DatabaseManager # noqa from autopush.router.apnsrouter import APNSRouter from autopush.router.gcm import GCMRouter @@ -15,7 +16,6 @@ from autopush.router.simple import SimpleRouter from autopush.router.webpush import WebPushRouter from autopush.router.fcm import FCMRouter -from autopush.settings import AutopushConfig # noqa __all__ = ["APNSRouter", "FCMRouter", "GCMRouter", "WebPushRouter", "SimpleRouter"] diff --git a/autopush/router/apnsrouter.py b/autopush/router/apnsrouter.py index b2029ef0..78863ad5 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.AutopushConfig + :type ap_settings: autopush.config.AutopushConfig :param router_conf: Router specific configuration :type router_conf: dict :param load_connections: (used for testing) diff --git a/autopush/tests/support.py b/autopush/tests/support.py index 6b4fa438..4e5e5034 100644 --- a/autopush/tests/support.py +++ b/autopush/tests/support.py @@ -2,13 +2,13 @@ from twisted.logger import ILogObserver from zope.interface import implementer +from autopush.config import DDBTableConfig from autopush.db import ( DatabaseManager, Router, Storage ) from autopush.metrics import SinkMetrics -from autopush.settings import DDBTableConfig @implementer(ILogObserver) diff --git a/autopush/tests/test_endpoint.py b/autopush/tests/test_endpoint.py index d4c6398b..2cbc0cbb 100644 --- a/autopush/tests/test_endpoint.py +++ b/autopush/tests/test_endpoint.py @@ -10,6 +10,7 @@ import autopush.utils as utils +from autopush.config import AutopushConfig from autopush.db import ( ProvisionedThroughputExceededException, Message, @@ -21,7 +22,6 @@ from autopush.metrics import SinkMetrics from autopush.router import routers_from_settings from autopush.router.interface import IRouter -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 diff --git a/autopush/tests/test_health.py b/autopush/tests/test_health.py index ed6ec066..d13660ce 100644 --- a/autopush/tests/test_health.py +++ b/autopush/tests/test_health.py @@ -9,11 +9,11 @@ from twisted.trial import unittest from autopush import __version__ +from autopush.config import AutopushConfig from autopush.db import DatabaseManager from autopush.exceptions import MissingTableException from autopush.http import EndpointHTTPFactory from autopush.logging import begin_or_register -from autopush.settings import AutopushConfig from autopush.tests.client import Client from autopush.tests.support import TestingLogObserver from autopush.web.health import HealthHandler, StatusHandler diff --git a/autopush/tests/test_integration.py b/autopush/tests/test_integration.py index c06cacae..25fa4e8b 100644 --- a/autopush/tests/test_integration.py +++ b/autopush/tests/test_integration.py @@ -34,13 +34,13 @@ import autopush.db as db from autopush import __version__ +from autopush.config import AutopushConfig from autopush.db import ( get_month, has_connected_this_month ) from autopush.logging import begin_or_register from autopush.main import ConnectionApplication, EndpointApplication -from autopush.settings import AutopushConfig from autopush.utils import base64url_encode from autopush.metrics import SinkMetrics, DatadogMetrics from autopush.tests.support import TestingLogObserver diff --git a/autopush/tests/test_log_check.py b/autopush/tests/test_log_check.py index 81145b74..12c81ef2 100644 --- a/autopush/tests/test_log_check.py +++ b/autopush/tests/test_log_check.py @@ -6,9 +6,9 @@ from twisted.logger import globalLogPublisher from twisted.trial import unittest +from autopush.config import AutopushConfig from autopush.http import EndpointHTTPFactory from autopush.logging import begin_or_register -from autopush.settings import AutopushConfig from autopush.tests.client import Client from autopush.tests.support import TestingLogObserver from autopush.web.log_check import LogCheckHandler diff --git a/autopush/tests/test_main.py b/autopush/tests/test_main.py index ab6eb724..12bc5661 100644 --- a/autopush/tests/test_main.py +++ b/autopush/tests/test_main.py @@ -14,6 +14,7 @@ import hyper.tls import autopush.db +from autopush.config import AutopushConfig from autopush.db import DatabaseManager, get_rotating_message_table from autopush.exceptions import InvalidSettings from autopush.http import skip_request_logging @@ -21,7 +22,6 @@ ConnectionApplication, EndpointApplication, ) -from autopush.settings import AutopushConfig from autopush.tests.support import test_db from autopush.utils import resolve_ip diff --git a/autopush/tests/test_router.py b/autopush/tests/test_router.py index 64e8caac..080b7690 100644 --- a/autopush/tests/test_router.py +++ b/autopush/tests/test_router.py @@ -19,6 +19,7 @@ import pyfcm from hyper.http20.exceptions import HTTP20Error +from autopush.config import AutopushConfig from autopush.db import ( Message, ProvisionedThroughputExceededException, @@ -34,7 +35,6 @@ FCMRouter, ) from autopush.router.interface import RouterResponse, IRouter -from autopush.settings import AutopushConfig from autopush.tests import MockAssist from autopush.tests.support import test_db from autopush.web.base import Notification diff --git a/autopush/tests/test_web_base.py b/autopush/tests/test_web_base.py index e071774a..623b803f 100644 --- a/autopush/tests/test_web_base.py +++ b/autopush/tests/test_web_base.py @@ -9,10 +9,10 @@ from twisted.python.failure import Failure from twisted.trial import unittest +from autopush.config import AutopushConfig from autopush.db import ProvisionedThroughputExceededException from autopush.http import EndpointHTTPFactory from autopush.exceptions import InvalidRequest -from autopush.settings import AutopushConfig from autopush.metrics import SinkMetrics from autopush.tests.support import test_db diff --git a/autopush/tests/test_web_validation.py b/autopush/tests/test_web_validation.py index c17e509f..57a4fa8a 100644 --- a/autopush/tests/test_web_validation.py +++ b/autopush/tests/test_web_validation.py @@ -773,8 +773,8 @@ def test_old_current_month(self): class TestWebPushRequestSchemaUsingVapid(unittest.TestCase): def _make_fut(self): + from autopush.config import AutopushConfig from autopush.web.webpush import WebPushRequestSchema - 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 8217f94b..2abf7681 100644 --- a/autopush/tests/test_web_webpush.py +++ b/autopush/tests/test_web_webpush.py @@ -7,10 +7,10 @@ from twisted.internet.defer import inlineCallbacks from twisted.trial import unittest +from autopush.config import AutopushConfig from autopush.db import Message from autopush.http import EndpointHTTPFactory from autopush.router.interface import IRouter, RouterResponse -from autopush.settings import AutopushConfig from autopush.tests.client import Client from autopush.tests.support import test_db diff --git a/autopush/tests/test_websocket.py b/autopush/tests/test_websocket.py index 6e4e58e2..77e1fda4 100644 --- a/autopush/tests/test_websocket.py +++ b/autopush/tests/test_websocket.py @@ -26,10 +26,10 @@ from twisted.web.client import Agent import autopush.db as db +from autopush.config import AutopushConfig from autopush.db import DatabaseManager from autopush.http import InternalRouterHTTPFactory from autopush.metrics import SinkMetrics -from autopush.settings import AutopushConfig from autopush.tests import MockAssist from autopush.utils import WebPushNotification from autopush.tests.client import Client diff --git a/autopush/websocket.py b/autopush/websocket.py index 01ee2f3b..5e1eba3d 100644 --- a/autopush/websocket.py +++ b/autopush/websocket.py @@ -84,6 +84,7 @@ from autopush import __version__ from autopush.base import BaseHandler +from autopush.config import AutopushConfig # noqa from autopush.db import ( has_connected_this_month, hasher, @@ -95,7 +96,6 @@ from autopush.noseplugin import track_object from autopush.protocol import IgnoreBody from autopush.metrics import IMetrics, make_tags # noqa -from autopush.settings import AutopushConfig # noqa from autopush.ssl import AutopushSSLContextFactory # noqa from autopush.types import JSONDict # noqa from autopush.utils import (