diff --git a/src/plotman/_tests/configuration_test.py b/src/plotman/_tests/configuration_test.py index 0f0e9d56..6ad2abb9 100644 --- a/src/plotman/_tests/configuration_test.py +++ b/src/plotman/_tests/configuration_test.py @@ -50,3 +50,18 @@ def test_get_validated_configs__missing(mocker, config_path): f"No 'plotman.yaml' file exists at expected location: '{nonexistent_config}'. To generate " f"default config file, run: 'plotman config generate'" ) + + +def test_loads_without_user_interface(mocker, config_path, tmp_path): + with open(config_path, "r") as file: + loaded_yaml = yaml.load(file, Loader=yaml.SafeLoader) + + del loaded_yaml["user_interface"] + + temporary_configuration_path = tmp_path.joinpath("config.yaml") + temporary_configuration_path.write_text(yaml.safe_dump(loaded_yaml)) + + mocker.patch("plotman.configuration.get_path", return_value=temporary_configuration_path) + reloaded_yaml = configuration.get_validated_configs() + + assert reloaded_yaml.user_interface == configuration.UserInterface() diff --git a/src/plotman/configuration.py b/src/plotman/configuration.py index 44b12c43..9e92ea5e 100644 --- a/src/plotman/configuration.py +++ b/src/plotman/configuration.py @@ -1,4 +1,4 @@ -from dataclasses import dataclass +from dataclasses import dataclass, field from typing import Dict, List, Optional import appdirs @@ -82,11 +82,11 @@ class Plotting: @dataclass class UserInterface: - use_stty_size: bool + use_stty_size: bool = True @dataclass class PlotmanConfig: - user_interface: UserInterface directories: Directories scheduling: Scheduling plotting: Plotting + user_interface: UserInterface = field(default_factory=UserInterface)