Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defaults for user interface #119

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/plotman/_tests/configuration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
6 changes: 3 additions & 3 deletions src/plotman/configuration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dataclasses import dataclass
from dataclasses import dataclass, field
from typing import Dict, List, Optional

import appdirs
Expand Down Expand Up @@ -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)