def test_should_override_with_environment_variables( self, temp_dir: Path, get_app_root_mock: MagicMock): temp_dir.joinpath('app-defaults.cfg').write_text( _dict_to_cfg_content({SECTION_1: { KEY_1: VALUE_1 }})) get_app_root_mock.return_value = str(temp_dir) os.environ['__'.join(['SCIENCEBEAM', SECTION_1, KEY_1]).upper()] = VALUE_2 app_config = read_app_config() assert app_config.get(SECTION_1, KEY_1) == VALUE_2
def test_should_override_config_with_app_cfg(self, tmpdir): tmpdir.join('app-defaults.cfg').write(_dict_to_cfg_content({ SECTION_1: {KEY_1: VALUE_1} })) tmpdir.join('app.cfg').write(_dict_to_cfg_content({ SECTION_1: {KEY_1: VALUE_2} })) m = app_config_module with patch.object(m, 'get_app_root') as get_app_root_mock: get_app_root_mock.return_value = str(tmpdir) app_config = read_app_config() assert app_config.get(SECTION_1, KEY_1) == VALUE_2
def test_should_read_actual_config(self): assert read_app_config()