Exemple #1
0
def test_db(metrics=None):
    """Return a test DatabaseManager: its Storage/Router are mocked"""
    return DatabaseManager(
        router_conf=DDBTableConfig(tablename='router'),
        router=Mock(spec=Router),
        message_conf=DDBTableConfig(tablename='message'),
        metrics=SinkMetrics() if metrics is None else metrics)
    def setUp(self):
        self.timeout = 4
        twisted.internet.base.DelayedCall.debug = True

        conf = AutopushConfig(
            hostname="localhost",
            statsd_host=None,
            router_table=DDBTableConfig(tablename="router_test"),
            message_table=DDBTableConfig(tablename="message_int_test"),
        )

        db = DatabaseManager.from_config(conf,
                                         resource=autopush.tests.boto_resource)
        db.setup_tables()

        # ignore logging
        logs = TestingLogObserver()
        begin_or_register(logs)
        self.addCleanup(globalLogPublisher.removeObserver, logs)

        app = EndpointHTTPFactory.for_handler(HealthHandler, conf, db=db)
        self.message = app.db.message
        self.client = Client(app)
Exemple #3
0
 def setUpClass(cls):
     cls.resource = autopush.tests.boto_resource
     cls.table_conf = DDBTableConfig("router_test")
     cls.router = test_router
Exemple #4
0
def setup_module():
    global test_router
    config = DDBTableConfig("router_test")
    test_router = Router(config,
                         SinkMetrics(),
                         resource=autopush.tests.boto_resource)
Exemple #5
0
 def setUp(cls):
     cls.resource = autopush.tests.boto_resource
     cls.table_conf = DDBTableConfig("router_test")
     cls.router = Router(cls.table_conf,
                         SinkMetrics(),
                         resource=cls.resource)