コード例 #1
0
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)
コード例 #2
0
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.")
コード例 #3
0
def test_loading_records(config: Config):
    """ Load test data from db """
    db_path = config.get(ConfigKeys.asset_allocation_database_path)
    full_path = path.abspath(db_path)
    log(DEBUG, f"db: {db_path}, {full_path}")

    x: AssetAllocationLoader = AssetAllocationLoader(config=config)
    # log(DEBUG, f"using configuration: {x.config}")
    actual = x.load_tree_from_db()

    assert len(actual.classes) == 2
コード例 #4
0
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.")
コード例 #5
0
def show():
    """ Show the contents of the current config file """
    cfg = Config()
    # file_path = cfg.get_config_path()
    contents = cfg.get_contents()
    print(contents)
コード例 #6
0
def delete():
    """ Delete the current user's config file """
    cfg = Config()
    cfg.delete_user_config()
コード例 #7
0
def config():
    """ Test configuration """
    return Config("data/asset_allocation.ini")
コード例 #8
0
def test_get_config_location():
    """ Get the config location from setuptools """
    cfg = Config()
    filename = cfg.get_config_path()
    assert "asset_allocation.ini" in filename
コード例 #9
0
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
コード例 #10
0
def test_config_read():
    """ Read config file """
    cfg = Config("data/asset_allocation.ini")
    content = cfg.get_contents()

    assert content is not None