diff --git a/kiwi_scp/config.py b/kiwi_scp/config.py index 3280f9a..ad9e923 100644 --- a/kiwi_scp/config.py +++ b/kiwi_scp/config.py @@ -45,13 +45,12 @@ class ProjectConfig(BaseModel): def kiwi_dict(self) -> Dict[str, Any]: """write this object as a dictionary of strings""" - if self.override_storage is None: - return {self.name: self.enabled} + result = self.dict(exclude={"override_storage"}) - else: - result = self.dict(exclude={"override_storage"}) + if self.override_storage is not None: result["override_storage"] = self.override_storage.kiwi_dict - return result + + return result @validator("name") @classmethod diff --git a/kiwi_scp/yaml.py b/kiwi_scp/yaml.py index 5caff50..2d7a606 100644 --- a/kiwi_scp/yaml.py +++ b/kiwi_scp/yaml.py @@ -10,7 +10,7 @@ from ._constants import HEADER_KIWI_CONF_NAME class YAML(ruamel.yaml.YAML): def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) - self.indent(offset=2) + self.indent(sequence=4, offset=2) def dump(self, data, stream=None, **kwargs) -> Optional[str]: into_str: bool = False diff --git a/tests/test_config.py b/tests/test_config.py index 3a344e0..33a4421 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -221,7 +221,12 @@ class TestProject: assert p.name == "project" assert not p.enabled assert p.override_storage is None - assert p.kiwi_dict == kiwi_dict + + resulting_kiwi_dict = { + "name": "project", + "enabled": False, + } + assert p.kiwi_dict == resulting_kiwi_dict def test_dict(self): c = KiwiConfig(projects={"name": "project"})