Example #1
0
def load_config(config_path: str) -> Config:
    """Configure the Config object."""
    try:
        return Config(config_path)
    except ConfigError as error:
        log.error(str(error))
        sys.exit(1)
Example #2
0
def fixture_config(tmpdir_factory: TempdirFactory) -> Config:
    """Configure the Config object for the tests."""
    data = tmpdir_factory.mktemp("data")
    config_file = str(data.join("config.yaml"))
    copyfile("tests/assets/config.yaml", config_file)
    config = Config(config_file)

    return config
Example #3
0
def test_set_active_project_works_if_existent(
    config: Config, caplog: LogCaptureFixture
) -> None:
    """
    Given: A configuration with configured project.
    When: Set that project as active.
    Then: The project is activated and the configuration is saved.
    """
    config.data = {
        "projects": {"project_1": {}},
    }

    services.set_active_project(config, "project_1")  # act

    # Reload the config from the file
    Config(config.config_path)
    assert config["active_project"] == "project_1"
    assert (
        "drode.services",
        logging.INFO,
        "The project project_1 is now active",
    ) in caplog.record_tuples