Update tank api and test

This commit is contained in:
wqy
2022-09-25 00:25:04 +08:00
parent 277f5a3501
commit 79fa7d3fae
6 changed files with 190 additions and 89 deletions

View File

@@ -21,7 +21,7 @@ def get_junction_schema(name: str) -> dict[str, dict[str, Any]]:
def _query_junction(name: str, id: str) -> Row | None:
return read(name, f"select id, elevation, demand, pattern from junctions where id = '{id}'")
return read(name, f"select * from junctions where id = '{id}'")
def add_junction(name: str, id: str, x: float, y: float, elevation: float) -> ChangeSet:
@@ -59,6 +59,9 @@ def get_junction(name: str, id: str) -> dict[str, Any] | None:
def set_junction(name: str, id: str, properties: dict[str, Any]) -> ChangeSet:
if not is_junction(name, id):
return ChangeSet()
if 'pattern' in properties:
if not is_pattern(properties['pattern']):
return ChangeSet()
old = Serialize(get_junction(name, id), schema).to_storage()