mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-12-24 18:22:59 +00:00
prefer "long" project configs
This commit is contained in:
parent
b76b6b59ed
commit
aa8f0d9e6a
3 changed files with 11 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"})
|
||||
|
|
Loading…
Reference in a new issue