Пример #1
0
    def __init__(self, app):
        """
        Create an application context object,

        :param app: Flask application instance.
        """
        self.config = ConfigClient()
        self.cache = CacheClient(
            addr=self.config.get_value('redis.addr'),
            prefix='orion',
        )
        self.db = DbClient(
            app,
            user=self.config.get_value('database.user'),
            password=self.config.get_value('database.password'),
            host=self.config.get_value('database.host'),
            port=self.config.get_value('database.port'),
            name=self.config.get_value('database.name'),
        )
        self.geocode = ReverseGeocodingClient(
            mapbox_access_token=self.config.get_value('mapbox_access_token'),
        )
        self.metrics_event = EventMetricsClient(
            addr=self.config.get_value('statsd.addr'),
            prefix='orion',
        )
        self.metrics_latency = LatencyMetricsClient(
            addr=self.config.get_value('statsd.addr'),
            prefix='orion',
        )
        self.stream = StreamClient(
            kafka_addr=self.config.get_value('kafka.addr'),
            kafka_topic=self.config.get_value('kafka.topic'),
        )
Пример #2
0
 def setUp(self):
     self.mock_app = flask.Flask(__name__)
     self.mock_ctx = mock.MagicMock()
     self.mock_ctx.cache = CacheClient(addr=None, prefix='prefix')
Пример #3
0
 def setUp(self, *args):
     self.redis_client = CacheClient('localhost:6379', 'prefix')
     self.memory_client = CacheClient(None, 'prefix')