Example #1
0
def test_load_handles_file_not_found(config: Config) -> None:
    """
    Given: An inexistent config file.
    When: configuration is loaded.
    Then: A ConfigError is returned.
    """
    config.config_path = "inexistent.yaml"

    with pytest.raises(ConfigError):
        config.load()
Example #2
0
def test_load_handles_wrong_file_format(yaml_mock: Mock,
                                        config: Config) -> None:
    """
    Given: A config file with wrong yaml format.
    When: configuration is loaded.
    Then: A ConfigError is returned.
    """
    yaml_mock.return_value.load.side_effect = ParserError(
        "error",
        FileMarkMock(),
        "problem",
        FileMarkMock(),
    )

    with pytest.raises(ConfigError):
        config.load()
Example #3
0
def test_config_load(config: Config) -> None:
    """Loading the configuration from the yaml file works."""
    config.load()  # act

    assert config.data["verbose"] == "info"