Ejemplo n.º 1
0
 def __init__(self, options):
     self.options = options
     self.config = yaml.safe_load(open(options['config'], "rb"))
     self.pools = self.config.get('pools', {})
     redis = RedisManager.from_config(self.config.get('redis_manager', {}))
     self.tagpool = TagpoolManager(
         redis.sub_manager(self.config.get('tagpool_prefix', 'vumi')))
Ejemplo n.º 2
0
 def __init__(self, options):
     self.options = options
     self.config = yaml.safe_load(open(options['config'], "rb"))
     self.pools = self.config.get('pools', {})
     redis = RedisManager.from_config(self.config.get('redis_manager', {}))
     self.tagpool = TagpoolManager(redis.sub_manager(
             self.config.get('tagpool_prefix', 'vumi')))
Ejemplo n.º 3
0
 def setup_backend(self, config):
     self.redis = RedisManager.from_config(config['redis_manager'])
     self.riak = RiakManager.from_config(config['riak_manager'])
     # this prefix is hard coded in VumiApi
     self.tagpool = TagpoolManager(
         self.redis.sub_manager('tagpool_store'))
     self.api = VumiApi(self.riak, self.redis)
Ejemplo n.º 4
0
 def from_config_sync(cls, config, amqp_client=None):
     riak_config, redis_config = cls._parse_config(config)
     manager = RiakManager.from_config(riak_config)
     redis = RedisManager.from_config(redis_config)
     sender = SyncMessageSender(amqp_client)
     metric_publisher = None
     if amqp_client is not None:
         metric_publisher = amqp_client.get_metric_publisher()
     return cls(manager, redis, sender, metric_publisher)
Ejemplo n.º 5
0
Archivo: api.py Proyecto: TouK/vumi-go
 def from_config_sync(cls, config, amqp_client=None):
     riak_config, redis_config = cls._parse_config(config)
     manager = RiakManager.from_config(riak_config)
     redis = RedisManager.from_config(redis_config)
     sender = SyncMessageSender(amqp_client)
     metric_publisher = None
     if amqp_client is not None:
         metric_publisher = amqp_client.get_metric_publisher()
     return cls(manager, redis, sender, metric_publisher)
Ejemplo n.º 6
0
 def get_redis(self, **kwargs):
     from vumi.persist.redis_manager import RedisManager
     # Fake redis
     fake_redis = RedisManager._fake_manager(FakeRedis(**kwargs), {
         "config": {},
         "key_prefix": 'redistest',
     })
     self.add_cleanup(fake_redis._close)
     # Real redis
     config = {
         'FAKE_REDIS': 'yes',
         'key_prefix': 'redistest',
     }
     config.update(kwargs)
     real_redis = RedisManager.from_config(config)
     self.add_cleanup(self.cleanup_manager, real_redis)
     real_redis._purge_all()
     # Both redises
     return RedisPairWrapper(self, fake_redis, real_redis)
Ejemplo n.º 7
0
 def get_redis(self, **kwargs):
     from vumi.persist.redis_manager import RedisManager
     # Fake redis
     fake_redis = RedisManager._fake_manager(FakeRedis(**kwargs), {
         "config": {},
         "key_prefix": 'redistest',
     })
     self.add_cleanup(fake_redis._close)
     # Real redis
     config = {
         'FAKE_REDIS': 'yes',
         'key_prefix': 'redistest',
     }
     config.update(kwargs)
     real_redis = RedisManager.from_config(config)
     self.add_cleanup(self.cleanup_manager, real_redis)
     real_redis._purge_all()
     # Both redises
     return RedisPairWrapper(self, fake_redis, real_redis)
Ejemplo n.º 8
0
class TestRedisManager(VumiTestCase):
    def setUp(self):
        try:
            from vumi.persist.redis_manager import RedisManager
        except ImportError, e:
            import_skip(e, 'redis')

        self.manager = RedisManager.from_config(
            {'FAKE_REDIS': 'yes',
             'key_prefix': 'redistest'})
        self.add_cleanup(self.cleanup_manager)
        self.manager._purge_all()
Ejemplo n.º 9
0
def get_poll_config(poll_id):
    # FIXME: Do we really need this?
    redis = RedisManager.from_config(settings.VXPOLLS_REDIS_CONFIG)
    pm = PollManager(redis, settings.VXPOLLS_PREFIX)
    config = pm.get_config(poll_id)
    config.update({
        'poll_id': poll_id,
    })

    config.setdefault('repeatable', True)
    config.setdefault('survey_completed_response',
                        'Thanks for completing the survey')
    return pm, config
Ejemplo n.º 10
0
def get_poll_config(poll_id):
    # FIXME: Do we really need this?
    redis = RedisManager.from_config(settings.VXPOLLS_REDIS_CONFIG)
    pm = PollManager(redis, settings.VXPOLLS_PREFIX)
    config = pm.get_config(poll_id)
    config.update({
        'poll_id': poll_id,
    })

    config.setdefault('repeatable', True)
    config.setdefault('survey_completed_response',
                      'Thanks for completing the survey')
    return pm, config
Ejemplo n.º 11
0
 def get_redis(self, config):
     """
     Create and return a redis manager.
     """
     redis_config = config.get("redis_manager", {})
     return RedisManager.from_config(redis_config)
Ejemplo n.º 12
0
 def get_redis(self, config):
     return RedisManager.from_config(config)
Ejemplo n.º 13
0
        if self.sync_persistence:
            return self._get_sync_redis_manager(config)
        return self._get_async_redis_manager(config)

    def _get_async_redis_manager(self, config):
        from vumi.persist.txredis_manager import TxRedisManager

        return TxRedisManager.from_config(config)

    def _get_sync_redis_manager(self, config):
        try:
            from vumi.persist.redis_manager import RedisManager
        except ImportError, e:
            import_skip(e, 'redis')

        return RedisManager.from_config(config)


class VumiWorkerTestCase(VumiTestCase):
    """Base test class for vumi workers.

    This (or a subclass of this) should be the starting point for any test
    cases that involve vumi workers.
    """

    transport_name = "sphex"
    transport_type = None

    MSG_ID_MATCHER = RegexMatcher(r'^[0-9a-fA-F]{32}$')

    def setUp(self):
Ejemplo n.º 14
0
 def get_redis(self, config):
     """
     Create and return a redis manager.
     """
     redis_config = config.get('redis_manager', {})
     return RedisManager.from_config(redis_config)
Ejemplo n.º 15
0
 def get_redis(self, config):
     return RedisManager.from_config(config)
Ejemplo n.º 16
0
        if self.sync_persistence:
            return self._get_sync_redis_manager(config)
        return self._get_async_redis_manager(config)

    def _get_async_redis_manager(self, config):
        from vumi.persist.txredis_manager import TxRedisManager

        return TxRedisManager.from_config(config)

    def _get_sync_redis_manager(self, config):
        try:
            from vumi.persist.redis_manager import RedisManager
        except ImportError, e:
            import_skip(e, 'redis')

        return RedisManager.from_config(config)


class VumiWorkerTestCase(VumiTestCase):
    """Base test class for vumi workers.

    This (or a subclass of this) should be the starting point for any test
    cases that involve vumi workers.
    """

    transport_name = "sphex"
    transport_type = None

    MSG_ID_MATCHER = RegexMatcher(r'^[0-9a-fA-F]{32}$')

    def setUp(self):