Skip to content

Commit

Permalink
Merge pull request #119 from altendky/defaults_for_user_interface
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky authored Apr 22, 2021
2 parents a6d821c + 5794f71 commit b0d7e8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
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)

0 comments on commit b0d7e8d

Please sign in to comment.