コード例 #1
0
def test_locations_configparser_chain_multi():

    os.environ['FOO'] = '1'
    os.environ['BAR'] = '2'
    os.environ['BAZ'] = '3'

    os.environ['TEST_SETTINGS'] = './tests/data/settings1.ini'

    config = Config(chain=True)
    config.locations = [
        Location.from_env_keys(['FOO', 'BAR', 'BAZ']),
        Location.from_env_path('TEST_SETTINGS'),
        Location.from_path('./tests/data/settings2.ini')
    ]

    assert config.data.FOO == '1'
    assert config.data.BAR == '2'
    assert config.data.BAZ == '3'

    assert config.data.section1['foo'] == '1'
    assert config.data.section1['bar'] == '2'
    assert config.data.section1['baz'] == '3'

    assert config.data.section2['dog'] == 'lucy'
    assert config.data.section2['cat'] == 'ollie'

    assert config.data.section3['zap'] == '1'
    assert config.data.section3['qux'] == '2'
    assert config.data.section3['quux'] == '3'

    assert config.data.section4['lucy'] == 'dog'
    assert config.data.section4['ollie'] == 'cat'
コード例 #2
0
def test_locations_configparser_chain_multi():

    os.environ['FOO'] = '1'
    os.environ['BAR'] = '2'
    os.environ['BAZ'] = '3'

    os.environ['TEST_SETTINGS'] = './tests/data/settings1.ini'

    config = Config(chain=True)
    config.locations = [
    Location.from_env_keys(['FOO', 'BAR', 'BAZ']),
    Location.from_env_path('TEST_SETTINGS'),
    Location.from_path('./tests/data/settings2.ini')
    ]

    assert config.data.FOO == '1'
    assert config.data.BAR == '2'
    assert config.data.BAZ == '3'

    assert config.data.section1['foo'] == '1'
    assert config.data.section1['bar'] == '2'
    assert config.data.section1['baz'] == '3'

    assert config.data.section2['dog'] == 'lucy'
    assert config.data.section2['cat'] == 'ollie'

    assert config.data.section3['zap'] == '1'
    assert config.data.section3['qux'] == '2'
    assert config.data.section3['quux'] == '3'

    assert config.data.section4['lucy'] == 'dog'
    assert config.data.section4['ollie'] == 'cat'
コード例 #3
0
ファイル: test_yaml.py プロジェクト: aubricus/confypy
def test_locations_yaml_chain_multi():

    os.environ['FOO'] = '1'
    os.environ['BAR'] = '2'
    os.environ['BAZ'] = '3'

    os.environ['TEST_SETTINGS'] = './tests/data/settings1.yaml'

    config = Config(chain=True)
    config.locations = [
    Location.from_env_keys(['FOO', 'BAR', 'BAZ']),
    Location.from_env_path('TEST_SETTINGS'),
    Location.from_path('./tests/data/settings2.yaml')
    ]

    assert config.data.FOO == '1'
    assert config.data.BAR == '2'
    assert config.data.BAZ == '3'

    assert config.data.name == 'Ollie'
    assert config.data.occupation == 'Cat'
    assert config.data.Sound == 'Meow'
    assert config.data['foo.bar.baz']['name'] == 'lucy'

    # testing extension
    assert config.data.extra1 == 1
    assert config.data.extra2 == 1
コード例 #4
0
ファイル: test_json.py プロジェクト: aventurella/confypy
def test_locations_json_chain_multi():

    os.environ['FOO'] = '1'
    os.environ['BAR'] = '2'
    os.environ['BAZ'] = '3'

    os.environ['TEST_SETTINGS'] = './tests/data/settings1.json'

    config = Config(chain=True)
    config.locations = [
        Location.from_env_keys(['FOO', 'BAR', 'BAZ']),
        Location.from_env_path('TEST_SETTINGS'),
        Location.from_path('./tests/data/settings2.json')
    ]

    assert config.data.FOO == '1'
    assert config.data.BAR == '2'
    assert config.data.BAZ == '3'

    assert config.data.name == 'Ollie'
    assert config.data.occupation == 'Cat'
    assert config.data.Sound == 'Meow'
    assert config.data['foo.bar.baz']['name'] == 'lucy'

    # testing extension
    assert config.data.extra1 == 1
    assert config.data.extra2 == 1

    #testing attribute dict
    assert config.data.extra3.foo.bar.baz == 'lucy'
コード例 #5
0
ファイル: test_yaml.py プロジェクト: aubricus/confypy
def test_locations_yaml_first_env():
    os.environ['TEST_SETTINGS'] = './tests/data/settings1.yaml'

    config = Config()
    config.locations = [Location.from_env_path('TEST_SETTINGS')]

    assert config.data.name == 'Lucy'
    assert config.data.occupation == 'Dog'
    assert config.data.Sound == 'Woof'
    assert config.data['foo.bar.baz']['name'] == 'ollie'
コード例 #6
0
def test_locations_yaml_first_env():
    os.environ['TEST_SETTINGS'] = './tests/data/settings1.yaml'

    config = Config()
    config.locations = [Location.from_env_path('TEST_SETTINGS')]

    assert config.data.name == 'Lucy'
    assert config.data.occupation == 'Dog'
    assert config.data.Sound == 'Woof'
    assert config.data['foo.bar.baz']['name'] == 'ollie'
コード例 #7
0
def test_locations_configparser_first_env():
    os.environ['TEST_SETTINGS'] = './tests/data/settings1.ini'

    config = Config()
    config.locations = [Location.from_env_path('TEST_SETTINGS')]

    assert config.data.section1['foo'] == '1'
    assert config.data.section1['bar'] == '2'
    assert config.data.section1['baz'] == '3'

    assert config.data.section2['dog'] == 'lucy'
    assert config.data.section2['cat'] == 'ollie'
コード例 #8
0
ファイル: test_yaml.py プロジェクト: aubricus/confypy
def test_locations_yaml_first_multi():
    os.environ['TEST_SETTINGS'] = './tests/data/settings2.yaml'

    config = Config()
    config.locations = [
    Location.from_env_path('TEST_SETTINGS'),
    Location.from_path('./tests/data/settings1.yaml')]

    assert config.data.name == 'Ollie'
    assert config.data.occupation == 'Cat'
    assert config.data.Sound == 'Meow'
    assert config.data['foo.bar.baz']['name'] == 'lucy'
コード例 #9
0
def test_locations_configparser_first_env():
    os.environ['TEST_SETTINGS'] = './tests/data/settings1.ini'

    config = Config()
    config.locations = [Location.from_env_path('TEST_SETTINGS')]

    assert config.data.section1['foo'] == '1'
    assert config.data.section1['bar'] == '2'
    assert config.data.section1['baz'] == '3'

    assert config.data.section2['dog'] == 'lucy'
    assert config.data.section2['cat'] == 'ollie'
コード例 #10
0
ファイル: test_json.py プロジェクト: aubricus/confypy
def test_locations_json_first_multi_fail():
    os.environ['TEST_SETTINGS'] = './tests/data/notfound'

    config = Config()
    config.locations = [
    Location.from_env_path('TEST_SETTINGS'),
    Location.from_path('./tests/data/settings1.json')]

    assert config.data.name == 'Lucy'
    assert config.data.occupation == 'Dog'
    assert config.data.Sound == 'Woof'
    assert config.data['foo.bar.baz']['name'] == 'ollie'
コード例 #11
0
ファイル: test_json.py プロジェクト: aventurella/confypy
def test_locations_json_first_multi_fail():
    os.environ['TEST_SETTINGS'] = './tests/data/notfound'

    config = Config()
    config.locations = [
        Location.from_env_path('TEST_SETTINGS'),
        Location.from_path('./tests/data/settings1.json')
    ]

    assert config.data.name == 'Lucy'
    assert config.data.occupation == 'Dog'
    assert config.data.Sound == 'Woof'
    assert config.data['foo.bar.baz']['name'] == 'ollie'
コード例 #12
0
ファイル: test_json.py プロジェクト: aventurella/confypy
def test_locations_json_first_multi():
    os.environ['TEST_SETTINGS'] = './tests/data/settings2.json'

    config = Config()
    config.locations = [
        Location.from_env_path('TEST_SETTINGS'),
        Location.from_path('./tests/data/settings1.json')
    ]

    assert config.data.name == 'Ollie'
    assert config.data.occupation == 'Cat'
    assert config.data.Sound == 'Meow'
    assert config.data['foo.bar.baz']['name'] == 'lucy'
コード例 #13
0
ファイル: test_json.py プロジェクト: aventurella/confypy
def test_locations_json_first_env():
    os.environ['TEST_SETTINGS'] = './tests/data/settings1.json'

    config = Config()
    config.locations = [Location.from_env_path('TEST_SETTINGS')]

    assert config.data.name == 'Lucy'
    assert config.data.occupation == 'Dog'
    assert config.data.Sound == 'Woof'
    assert config.data['foo.bar.baz']['name'] == 'ollie'

    # attribute dict test
    assert config.data['foo.bar.baz'].name == 'ollie'
    assert config.data.extra3.foo.bar.baz == 'lucy'
コード例 #14
0
ファイル: test_json.py プロジェクト: aubricus/confypy
def test_locations_json_first_env():
    os.environ['TEST_SETTINGS'] = './tests/data/settings1.json'

    config = Config()
    config.locations = [Location.from_env_path('TEST_SETTINGS')]

    assert config.data.name == 'Lucy'
    assert config.data.occupation == 'Dog'
    assert config.data.Sound == 'Woof'
    assert config.data['foo.bar.baz']['name'] == 'ollie'

    # attribute dict test
    assert config.data['foo.bar.baz'].name == 'ollie'
    assert config.data.extra3.foo.bar.baz == 'lucy'
コード例 #15
0
ファイル: test_yaml.py プロジェクト: aubricus/confypy
def test_locations_yaml_first_multi_defaults():
    os.environ['TEST_SETTINGS'] = './tests/data/notfound1'

    config = Config(defaults={
        'name': 'lorem',
        'occupation': 'ipsum',
        'Sound': 'latin'})

    config.locations = [
    Location.from_env_path('TEST_SETTINGS'),
    Location.from_path('./tests/data/notfound2')]

    assert config.data.name == 'lorem'
    assert config.data.occupation == 'ipsum'
    assert config.data.Sound == 'latin'
コード例 #16
0
def test_locations_configparser_first_multi():
    os.environ['TEST_SETTINGS'] = './tests/data/settings2.ini'

    config = Config()
    config.locations = [
        Location.from_env_path('TEST_SETTINGS'),
        Location.from_path('./tests/data/settings1.ini')
    ]

    assert config.data.section3['zap'] == '1'
    assert config.data.section3['qux'] == '2'
    assert config.data.section3['quux'] == '3'

    assert config.data.section4['lucy'] == 'dog'
    assert config.data.section4['ollie'] == 'cat'
コード例 #17
0
def test_locations_configparser_first_multi():
    os.environ['TEST_SETTINGS'] = './tests/data/settings2.ini'

    config = Config()
    config.locations = [
        Location.from_env_path('TEST_SETTINGS'),
        Location.from_path('./tests/data/settings1.ini')
    ]

    assert config.data.section3['zap'] == '1'
    assert config.data.section3['qux'] == '2'
    assert config.data.section3['quux'] == '3'

    assert config.data.section4['lucy'] == 'dog'
    assert config.data.section4['ollie'] == 'cat'
コード例 #18
0
def test_locations_configparser_first_multi_keys():

    os.environ['FOO'] = '1'
    os.environ['BAR'] = '2'
    os.environ['BAZ'] = '3'

    config = Config()
    config.locations = [
        Location.from_env_keys(['FOO', 'BAR', 'BAZ']),
        Location.from_env_path('TEST_SETTINGS'),
        Location.from_path('./tests/data/notfound2')
    ]

    assert config.data.FOO == '1'
    assert config.data.BAR == '2'
    assert config.data.BAZ == '3'
コード例 #19
0
ファイル: test_yaml.py プロジェクト: aubricus/confypy
def test_locations_yaml_first_multi_keys():

    os.environ['FOO'] = '1'
    os.environ['BAR'] = '2'
    os.environ['BAZ'] = '3'

    config = Config()
    config.locations = [
    Location.from_env_keys(['FOO', 'BAR', 'BAZ']),
    Location.from_env_path('TEST_SETTINGS'),
    Location.from_path('./tests/data/notfound2')
    ]

    assert config.data.FOO == '1'
    assert config.data.BAR == '2'
    assert config.data.BAZ == '3'
コード例 #20
0
def test_locations_configparser_first_multi_defaults():
    os.environ['TEST_SETTINGS'] = './tests/data/notfound1'

    config = Config(defaults={
        'name': 'lorem',
        'occupation': 'ipsum',
        'Sound': 'latin'
    })

    config.locations = [
        Location.from_env_path('TEST_SETTINGS'),
        Location.from_path('./tests/data/notfound2')
    ]

    assert config.data.name == 'lorem'
    assert config.data.occupation == 'ipsum'
    assert config.data.Sound == 'latin'
コード例 #21
0
ファイル: configuration.py プロジェクト: aventurella/burn-www
from confypy import Config, Location

settings = Config()
settings.locations = [
    Location.from_env_path('BURN_CONFIG')
]
コード例 #22
0
def test_missing_env_path():
    obj = Location.from_env_path('TEST_SETTINGS', parser='yaml')
    assert obj == {}