mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-12-24 18:22:59 +00:00
one less exception
This commit is contained in:
parent
2a8764577f
commit
1dcf542c6d
2 changed files with 2 additions and 7 deletions
|
@ -154,15 +154,13 @@ class KiwiConfig(BaseModel):
|
|||
|
||||
return cls()
|
||||
|
||||
def get_project_config(self, name: str) -> ProjectConfig:
|
||||
def get_project_config(self, name: str) -> Optional[ProjectConfig]:
|
||||
"""returns the config of a project with a given name"""
|
||||
|
||||
for project in self.projects:
|
||||
if project.name == name:
|
||||
return project
|
||||
|
||||
raise ValueError("No Such Project")
|
||||
|
||||
@property
|
||||
def kiwi_dict(self) -> Dict[str, Any]:
|
||||
"""write this object as a dictionary of strings"""
|
||||
|
|
|
@ -149,10 +149,7 @@ class TestProject:
|
|||
assert c == KiwiConfig(projects=[])
|
||||
assert c.projects == []
|
||||
|
||||
with pytest.raises(ValueError) as exc_info:
|
||||
c.get_project_config("invalid")
|
||||
|
||||
assert str(exc_info.value) == "No Such Project"
|
||||
assert c.get_project_config("invalid") is None
|
||||
|
||||
def test_long(self):
|
||||
kiwi_dict = {
|
||||
|
|
Loading…
Reference in a new issue