def test_connect_to_db(): """ Try to open database """ cfg = Config() db_path = cfg.get(ConfigKeys.asset_allocation_database_path) session = dal.get_session(db_path) print(session)
def get(aadb: str): """ Retrieves a value from config """ if (aadb): cfg = Config() value = cfg.get(ConfigKeys.asset_allocation_database_path) click.echo(value) if not aadb: click.echo("Use --help for more information.")
def set(aadb, cur): """ Sets the values in the config file """ cfg = Config() edited = False if aadb: cfg.set(ConfigKeys.asset_allocation_database_path, aadb) print(f"The database has been set to {aadb}.") edited = True if cur: cfg.set(ConfigKeys.default_currency, cur) edited = True if edited: print(f"Changes saved.") else: print(f"No changes were made.") print(f"Use --help parameter for more information.")
def show(): """ Show the contents of the current config file """ cfg = Config() # file_path = cfg.get_config_path() contents = cfg.get_contents() print(contents)
def delete(): """ Delete the current user's config file """ cfg = Config() cfg.delete_user_config()
def config(): """ Test configuration """ return Config("data/asset_allocation.ini")
def test_get_config_location(): """ Get the config location from setuptools """ cfg = Config() filename = cfg.get_config_path() assert "asset_allocation.ini" in filename
def test_user_config_created(): """ test if the user configuration instance is created """ cfg = Config() ini_path = cfg.get_config_path() assert ini_path is not None
def test_config_read(): """ Read config file """ cfg = Config("data/asset_allocation.ini") content = cfg.get_contents() assert content is not None