Exemplo n.º 1
0
class example1(object):
    config = C.Config('example1')

    ini = '''\
[example1]
pgdir = mypgdir
pgconf = my.conf
services_list =
    first
    second
    third
'''

    yaml = '''\
pgdir: mypgdir
pgconf: my.conf
services:
    - first
    - second
    - third
'''

    json = '''\
{
    "pgdir": "mypgdir",
    "pgconf": "my.conf",
    "services": [
        "first",
        "second",
        "third"
    ]
}
'''

    environ = {
        'PATH': 'A:B:C',
        'EXAMPLE1_PGDIR': 'mypgdir',
        'EXAMPLE1_PGCONF': 'my.conf',
        'EXAMPLE1_SERVICES_LIST': 'first second third',
    }

    import argparse
    cli_args = argparse.Namespace(
        pgdir='mypgdir',
        pgconf='my.conf',
        services=['first', 'second', 'third'],
    )

    parsed = {
        'pgdir': 'mypgdir',
        'pgconf': 'my.conf',
        'services': ['first', 'second', 'third'],
    }

    parameters = parametrize('format,suffix', (
        ('ini', 'ini'),
        ('ini', 'conf'),
        ('yaml', 'yaml'),
        ('yaml', 'yml'),
        ('json', 'json'),
    ))
Exemplo n.º 2
0
 def it_has_parity_with_file_configs(self):
     config = C.Config(projectname='example1')
     assert config.from_environ(example1.environ) == example1.parsed
Exemplo n.º 3
0
 def it_can_parse_the_environ(self):
     config = C.Config(projectname='example1')
     with mock.patch.dict(os.environ, example1.environ):
         assert config.from_environ() == example1.parsed
Exemplo n.º 4
0
 def it_can_parse(self):
     config = C.Config(projectname='my')
     assert config.from_environ({'MY_X': 2, 'MYY': 3, 'Z': 4}) == {'x': 2}