Esempio n. 1
0
def store_mpt_consul_config():
    import consul
    sample = {'project': {'variable': 2}}
    c = consul.Consul(host=CONSUL_HOST, port=CONSUL_PORT)
    for path, value in mp_serialize_dict(sample, separator='/'):
        c.kv.put(path, value)
    return c
def store_redis_config():
    import redis
    sample = {
        'bool_flag': '',  # flag
        'unicode': 'вася',
        # TODO: they've changed something under the hood
        #   None now is not supported. Have to do with it something later.
        #   Take a look at utils.mp_serialize_dict
        # 'none_value': None,
        'debug': True,
        'mixed': ['ascii', 'юникод', 1, {
            'd': 1
        }, {
            'b': 2
        }],
        'nested': {
            'a': {
                'b': 2
            }
        }
    }
    c = redis.Redis(host=REDIS_HOST, port=REDIS_PORT)
    for path, value in mp_serialize_dict(sample, separator='.'):
        c.set(path, value)
        c.set('my-prefix:%s' % path, value)
Esempio n. 3
0
    def test__utils__mp_serialize_dict(self):
        sample = {
            'bool_flag': '',  # flag
            'unicode': 'вася',
            'none_value': None,
            'debug': True,
            'mixed': ['ascii', 'юникод', 1, {'d': 1}, {'b': 2}],
            'nested': {
                'a': {
                    'b': 2,
                    'c': b'bytes',
                }
            }
        }

        result = [
            ('nested/a/b', b'2'),
            ('nested/a/c', b'bytes'),
            ('bool_flag', b"::YAML::\n''\n"),
            ('debug', b'true'),
            ('mixed', b'::YAML::\n- ascii\n- "\\u044E\\u043D\\u0438\\u043A\\u043E\\u0434"\n- 1\n- {d: 1}\n- {b: 2}\n'),
            ('none_value', None),
            ('unicode', b'\xd0\xb2\xd0\xb0\xd1\x81\xd1\x8f')
        ]

        md = utils.mp_serialize_dict(sample, separator='/')
        assert md == result
Esempio n. 4
0
def store_mpt_redis_config():
    import redis
    sample = {'project': {'i': {'am': {'redis': True}}}}
    c = redis.Redis(host=REDIS_HOST, port=REDIS_PORT)
    for path, value in mp_serialize_dict(sample, separator='.'):
        c.set(path, value)
        c.set('my-prefix:%s' % path, value)

    return c
def store_consul_config():
    import consul
    sample = {
        'bool_flag': '',  # flag
        'unicode': 'вася',
        'none_value': None,
        'debug': True,
        'mixed': ['ascii', 'юникод', 1, {
            'd': 1
        }, {
            'b': 2
        }],
        'nested': {
            'a': {
                'b': 2
            }
        }
    }
    c = consul.Consul(host=CONSUL_HOST, port=CONSUL_PORT)
    for path, value in mp_serialize_dict(sample, separator='/'):
        c.kv.put(path, value)
Esempio n. 6
0
def store_redis_config():
    import redis
    sample = {
        'bool_flag': '',  # flag
        'unicode': 'вася',
        'none_value': None,
        'debug': True,
        'mixed': ['ascii', 'юникод', 1, {
            'd': 1
        }, {
            'b': 2
        }],
        'nested': {
            'a': {
                'b': 2
            }
        }
    }
    c = redis.Redis(host=REDIS_HOST, port=REDIS_PORT)
    for path, value in mp_serialize_dict(sample, separator='.'):
        c.set(path, value)
        c.set('my-prefix:%s' % path, value)