def test_load_config(mock_file): mock_file('default.ini', dedent(''' [section] key: value ''')) env = environment.Environment('default') assert env['section']['key'] == 'value'
def test_default_section_not_in_sections(mock_file): mock_file( 'default.ini', dedent(''' [DEFAULT] default_key: default_value [section] key: value ''')) env = environment.Environment('default') assert env.sections() == ['section']
def test_load_multiple_sections(mock_file): mock_file( 'default.ini', dedent(''' [DEFAULT] default_key: default_value [section] key: value ''')) env = environment.Environment('default') assert env['section']['key'] == 'value' assert env['DEFAULT']['default_key'] == 'default_value'
def test_interpolation(mock_file): mock_file( 'default.ini', dedent(''' [DEFAULT] url: localhost sub_url: ${url}/sub_url [section] section_url: ${DEFAULT:url}/section_url ''')) env = environment.Environment('default') assert env['DEFAULT']['sub_url'] == 'localhost/sub_url' assert env['section']['section_url'] == 'localhost/section_url'
def test_load_empty_config_doesnt_fail(mock_file): mock_file('default.ini', '') env = environment.Environment('default')