1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-11-21 20:33:00 +00:00

prefer "long" project configs

This commit is contained in:
Jörn-Michael Miehe 2022-02-21 22:46:50 +01:00
parent b76b6b59ed
commit aa8f0d9e6a
3 changed files with 11 additions and 7 deletions

View file

@ -45,13 +45,12 @@ class ProjectConfig(BaseModel):
def kiwi_dict(self) -> Dict[str, Any]: def kiwi_dict(self) -> Dict[str, Any]:
"""write this object as a dictionary of strings""" """write this object as a dictionary of strings"""
if self.override_storage is None: result = self.dict(exclude={"override_storage"})
return {self.name: self.enabled}
else: if self.override_storage is not None:
result = self.dict(exclude={"override_storage"})
result["override_storage"] = self.override_storage.kiwi_dict result["override_storage"] = self.override_storage.kiwi_dict
return result
return result
@validator("name") @validator("name")
@classmethod @classmethod

View file

@ -10,7 +10,7 @@ from ._constants import HEADER_KIWI_CONF_NAME
class YAML(ruamel.yaml.YAML): class YAML(ruamel.yaml.YAML):
def __init__(self, *args, **kwargs) -> None: def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.indent(offset=2) self.indent(sequence=4, offset=2)
def dump(self, data, stream=None, **kwargs) -> Optional[str]: def dump(self, data, stream=None, **kwargs) -> Optional[str]:
into_str: bool = False into_str: bool = False

View file

@ -221,7 +221,12 @@ class TestProject:
assert p.name == "project" assert p.name == "project"
assert not p.enabled assert not p.enabled
assert p.override_storage is None 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): def test_dict(self):
c = KiwiConfig(projects={"name": "project"}) c = KiwiConfig(projects={"name": "project"})