def test_save_configuration(self, parus_properties): c = config.Configuration( default=config.Properties(folder_id='xxx')) c.save(parus_properties) saved = read_properties_file(parus_properties) assert saved['DEFAULT']['folder-id'] == 'xxx'
def test_load_default_folder(self, parus_config, parus_properties): conf = config.Configuration( default=config.Properties( folder_id='default-folder-id')) parus_config.create_properties_file(parus_properties, configuration=conf) folder_id = config.get_default_folder_id() assert folder_id == 'default-folder-id'
def test_load_configuration(self, parus_properties): c = configparser.ConfigParser() c['DEFAULT'] = { 'folder-id': 'xxx', } with open(parus_properties, 'w') as fp: c.write(fp) loaded_conf = config.Configuration.load(parus_properties) assert loaded_conf == config.Configuration( default=config.Properties( folder_id='xxx'))
class TestGetDefaultFolder: def test_load_default_folder(self, parus_config, parus_properties): conf = config.Configuration( default=config.Properties( folder_id='default-folder-id')) parus_config.create_properties_file(parus_properties, configuration=conf) folder_id = config.get_default_folder_id() assert folder_id == 'default-folder-id' @pytest.mark.parametrize('conf', [ config.Configuration(default=config.Properties(folder_id=None)), config.Configuration(default=None), None, ]) def test_no_default_folder(self, conf, parus_properties, parus_config): parus_config.create_properties_file(parus_properties, configuration=conf) folder_id = config.get_default_folder_id() assert folder_id is None
class TestSave: def test_save_configuration(self, parus_properties): c = config.Configuration( default=config.Properties(folder_id='xxx')) c.save(parus_properties) saved = read_properties_file(parus_properties) assert saved['DEFAULT']['folder-id'] == 'xxx' @pytest.mark.parametrize('default_prop', [ config.Properties(folder_id=None), None, ]) def test_clear_default_property_when_none( self, default_prop, parus_config, parus_properties): parus_config.create_dummy_properties(parus_properties) c = config.Configuration(default=default_prop) c.save(parus_properties) saved = read_properties_file(parus_properties) assert not_in_config(saved, 'DEFAULT', 'folder-id')
def create_dummy_properties(self, p_file): conf = config.Configuration( default=config.Properties( folder_id='default-folder-id')) self.create_properties_file(p_file, conf)