def test_exists(): """Test the functionality for whether the file exists.""" conf = seamm_installer.Configuration() assert not conf.file_exists() conf.path = "./does_not_exist.ini" assert not conf.file_exists() path = Path(__file__).resolve().parent conf.path = path / "data" / "seamm.ini" assert conf.file_exists()
def conf(): """Create a simple configuration for scratch.""" text = """\ This is a simple prolog. [TEST] # This is a test section. value1 = 53 value2 = 54 """ conf = seamm_installer.Configuration() conf.from_string(text) return conf
def __init__(self, ini_file="~/SEAMM/seamm.ini", logger=logger): # Create the ini file if it does not exist. self._check_ini_file(ini_file) self.logger = logger # and make the configuration, conda and pip objects self._configuration = seamm_installer.Configuration(ini_file) self._conda = seamm_installer.Conda() self._pip = seamm_installer.Pip() # Setup the parseer for the command-line self.options = None self.subparser = {} self.parser = self.setup_parser()
def test_create_configuration(conf): """Test creating a configuration from scratch.""" prolog = """\ This is a simple prolog. """ section_data = """\ # This is a test section. value1 = 53 value2 = 54 """ conf2 = seamm_installer.Configuration() conf2.add_prolog(prolog) conf2.add_section("TEST", section_data) assert str(conf2) == str(conf) assert conf2 == conf
def test_empty_prolog(): """Test what happens when ther is no prolog.""" conf = seamm_installer.Configuration() assert conf.get_prolog() == ""
def test_construction(): """Just create an object and test its type.""" result = seamm_installer.Configuration() assert str(type(result)) == ( "<class 'seamm_installer.configuration.Configuration'>" # noqa: E501 )
def seamm_conf(): """Create a configuration initialized with seamm.ini.""" return seamm_installer.Configuration(data_path / "seamm.ini")