Merge branch 'master' of https://e.coding.net/tjwater/tjwatercloud/TJWaterServer
This commit is contained in:
@@ -11,6 +11,9 @@ def get_pattern_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
|
||||
|
||||
def get_pattern(name: str, id: str) -> dict[str, Any]:
|
||||
p_one = try_read(name, f"select * from _pattern where id = '{id}'")
|
||||
if p_one == None:
|
||||
return {}
|
||||
pas = read_all(name, f"select * from patterns where id = '{id}' order by _order")
|
||||
ps = []
|
||||
for r in pas:
|
||||
@@ -46,6 +49,10 @@ def set_pattern_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def set_pattern(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_pattern(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, set_pattern_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -70,6 +77,10 @@ def add_pattern_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def add_pattern(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_pattern(name, cs.operations[0]['id']) != {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, add_pattern_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -94,6 +105,10 @@ def delete_pattern_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def delete_pattern(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_pattern(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, delete_pattern_cmd(name, cs))
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@ def get_curve_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
|
||||
|
||||
def get_curve(name: str, id: str) -> dict[str, Any]:
|
||||
c_one = read(name, f"select * from _curve where id = '{id}'")
|
||||
c_one = try_read(name, f"select * from _curve where id = '{id}'")
|
||||
if c_one == None:
|
||||
return {}
|
||||
cus = read_all(name, f"select * from curves where id = '{id}' order by _order")
|
||||
cs = []
|
||||
for r in cus:
|
||||
@@ -66,6 +68,10 @@ def set_curve_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def set_curve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_curve(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, set_curve_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -94,6 +100,10 @@ def add_curve_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def add_curve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_curve(name, cs.operations[0]['id']) != {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, add_curve_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -120,6 +130,10 @@ def delete_curve_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def delete_curve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_curve(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, delete_curve_cmd(name, cs))
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,9 @@ def get_mixing_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
|
||||
|
||||
def get_mixing(name: str, tank: str) -> dict[str, Any]:
|
||||
m = read(name, f"select * from mixing where tank = '{tank}'")
|
||||
m = try_read(name, f"select * from mixing where tank = '{tank}'")
|
||||
if m == None:
|
||||
return {}
|
||||
d = {}
|
||||
d['tank'] = str(m['tank'])
|
||||
d['model'] = str(m['model'])
|
||||
@@ -61,6 +63,10 @@ def set_mixing_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def set_mixing(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'tank' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_mixing(name, cs.operations[0]['tank']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, set_mixing_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -77,6 +83,10 @@ def add_mixing_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def add_mixing(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'tank' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_mixing(name, cs.operations[0]['tank']) != {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, add_mixing_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -93,6 +103,10 @@ def delete_mixing_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def delete_mixing(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'tank' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_mixing(name, cs.operations[0]['tank']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, delete_mixing_cmd(name, cs))
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@ def _to_client_point(coord: str) -> dict[str, float]:
|
||||
|
||||
|
||||
def get_node_coord(name: str, id: str) -> dict[str, float]:
|
||||
row = read(name, f"select * from coordinates where node = '{id}'")
|
||||
row = try_read(name, f"select * from coordinates where node = '{id}'")
|
||||
if row == None:
|
||||
return {}
|
||||
return _to_client_point(row['coord'])
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@ def get_junction_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
|
||||
|
||||
def get_junction(name: str, id: str) -> dict[str, Any]:
|
||||
j = read(name, f"select * from junctions where id = '{id}'")
|
||||
j = try_read(name, f"select * from junctions where id = '{id}'")
|
||||
if j == None:
|
||||
return {}
|
||||
xy = get_node_coord(name, id)
|
||||
d = {}
|
||||
d['id'] = str(j['id'])
|
||||
@@ -67,6 +69,10 @@ def set_junction_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def set_junction(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_junction(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, set_junction_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -88,6 +94,10 @@ def add_junction_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def add_junction(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_junction(name, cs.operations[0]['id']) != {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, add_junction_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -109,6 +119,10 @@ def delete_junction_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def delete_junction(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_junction(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, delete_junction_cmd(name, cs))
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,9 @@ def get_reservoir_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
|
||||
|
||||
def get_reservoir(name: str, id: str) -> dict[str, Any]:
|
||||
r = read(name, f"select * from reservoirs where id = '{id}'")
|
||||
r = try_read(name, f"select * from reservoirs where id = '{id}'")
|
||||
if r == None:
|
||||
return {}
|
||||
xy = get_node_coord(name, id)
|
||||
d = {}
|
||||
d['id'] = str(r['id'])
|
||||
@@ -71,6 +73,10 @@ def set_reservoir_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def set_reservoir(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_reservoir(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, set_reservoir_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -92,6 +98,10 @@ def add_reservoir_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def add_reservoir(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_reservoir(name, cs.operations[0]['id']) != {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, add_reservoir_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -113,6 +123,10 @@ def delete_reservoir_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def delete_reservoir(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_reservoir(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, delete_reservoir_cmd(name, cs))
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,9 @@ def get_tank_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
|
||||
|
||||
def get_tank(name: str, id: str) -> dict[str, Any]:
|
||||
t = read(name, f"select * from tanks where id = '{id}'")
|
||||
t = try_read(name, f"select * from tanks where id = '{id}'")
|
||||
if t == None:
|
||||
return {}
|
||||
xy = get_node_coord(name, id)
|
||||
d = {}
|
||||
d['id'] = str(t['id'])
|
||||
@@ -99,6 +101,10 @@ def set_tank_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def set_tank(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_tank(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, set_tank_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -120,6 +126,10 @@ def add_tank_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def add_tank(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_tank(name, cs.operations[0]['id']) != {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, add_tank_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -141,6 +151,10 @@ def delete_tank_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def delete_tank(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_tank(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, delete_tank_cmd(name, cs))
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,9 @@ def get_pipe_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
|
||||
|
||||
def get_pipe(name: str, id: str) -> dict[str, Any]:
|
||||
p = read(name, f"select * from pipes where id = '{id}'")
|
||||
p = try_read(name, f"select * from pipes where id = '{id}'")
|
||||
if p == None:
|
||||
return {}
|
||||
d = {}
|
||||
d['id'] = str(p['id'])
|
||||
d['node1'] = str(p['node1'])
|
||||
@@ -82,6 +84,10 @@ def set_pipe_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def set_pipe(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_pipe(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, set_pipe_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -101,6 +107,10 @@ def add_pipe_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def add_pipe(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_pipe(name, cs.operations[0]['id']) != {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, add_pipe_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -120,6 +130,10 @@ def delete_pipe_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def delete_pipe(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_pipe(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, delete_pipe_cmd(name, cs))
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,9 @@ def get_pump_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
|
||||
|
||||
def get_pump(name: str, id: str) -> dict[str, Any]:
|
||||
p = read(name, f"select * from pumps where id = '{id}'")
|
||||
p = try_read(name, f"select * from pumps where id = '{id}'")
|
||||
if p == None:
|
||||
return {}
|
||||
d = {}
|
||||
d['id'] = str(p['id'])
|
||||
d['node1'] = str(p['node1'])
|
||||
@@ -73,6 +75,10 @@ def set_pump_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def set_pump(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_pump(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, set_pump_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -92,6 +98,10 @@ def add_pump_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def add_pump(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_pump(name, cs.operations[0]['id']) != {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, add_pump_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -111,6 +121,10 @@ def delete_pump_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def delete_pump(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_pump(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, delete_pump_cmd(name, cs))
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,9 @@ def get_valve_schema(name: str) -> dict[str, dict[str, Any]]:
|
||||
|
||||
|
||||
def get_valve(name: str, id: str) -> dict[str, Any]:
|
||||
p = read(name, f"select * from valves where id = '{id}'")
|
||||
p = try_read(name, f"select * from valves where id = '{id}'")
|
||||
if p == None:
|
||||
return {}
|
||||
d = {}
|
||||
d['id'] = str(p['id'])
|
||||
d['node1'] = str(p['node1'])
|
||||
@@ -81,6 +83,10 @@ def set_valve_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def set_valve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_valve(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, set_valve_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -100,6 +106,10 @@ def add_valve_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def add_valve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_valve(name, cs.operations[0]['id']) != {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, add_valve_cmd(name, cs))
|
||||
|
||||
|
||||
@@ -119,6 +129,10 @@ def delete_valve_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def delete_valve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 'id' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
if get_valve(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, delete_valve_cmd(name, cs))
|
||||
|
||||
|
||||
|
||||
@@ -76,6 +76,8 @@ def set_tag_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def set_tag(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
if 't_type' not in cs.operations[0] or 'id' not in cs.operations[0] or 'tag' not in cs.operations[0]:
|
||||
return ChangeSet()
|
||||
return execute_command(name, set_tag_cmd(name, cs))
|
||||
|
||||
|
||||
|
||||
@@ -185,6 +185,63 @@ class TestApi:
|
||||
self.leave(p)
|
||||
|
||||
|
||||
# complex test
|
||||
|
||||
|
||||
def test_delete_node_link_then_restore(self):
|
||||
p = 'test_remove_node_link_then_restore'
|
||||
read_inp(p, f'./inp/net3.inp', '2')
|
||||
|
||||
open_project(p)
|
||||
|
||||
nodes = []
|
||||
links = []
|
||||
|
||||
nodes.append('131')
|
||||
links += get_node_links(p, nodes[-1])
|
||||
delete_junction(p, ChangeSet({'id': '131'}))
|
||||
|
||||
links.append('137')
|
||||
delete_pipe(p, ChangeSet({'id': '137'}))
|
||||
|
||||
nodes.append('129')
|
||||
links += get_node_links(p, nodes[-1])
|
||||
delete_junction(p, ChangeSet({'id': '129'}))
|
||||
|
||||
nodes.append('127')
|
||||
links += get_node_links(p, nodes[-1])
|
||||
delete_junction(p, ChangeSet({'id': '127'}))
|
||||
|
||||
links.append('135')
|
||||
delete_pipe(p, ChangeSet({'id': '135'}))
|
||||
|
||||
links.append('135')
|
||||
delete_pipe(p, ChangeSet({'id': '133'}))
|
||||
|
||||
nodes.append('20')
|
||||
links += get_node_links(p, nodes[-1])
|
||||
delete_junction(p, ChangeSet({'id': '20'}))
|
||||
|
||||
nodes.append('3')
|
||||
links += get_node_links(p, nodes[-1])
|
||||
delete_tank(p, ChangeSet({'id': '3'}))
|
||||
|
||||
for node in nodes:
|
||||
assert is_node(p, node) == False
|
||||
for link in links:
|
||||
assert is_link(p, link) == False
|
||||
|
||||
op = get_restore_operation(p)
|
||||
pick_operation(p, op)
|
||||
|
||||
for node in nodes:
|
||||
assert is_node(p, node)
|
||||
for link in links:
|
||||
assert is_link(p, link)
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
# 1 title
|
||||
|
||||
|
||||
@@ -249,6 +306,8 @@ class TestApi:
|
||||
p = 'test_junction'
|
||||
self.enter(p)
|
||||
|
||||
assert get_junction(p, 'j0') == {}
|
||||
|
||||
add_junction(p, ChangeSet({'id': 'j0', 'x': 0.0, 'y': 10.0, 'elevation': 20.0}))
|
||||
j0 = get_junction(p, 'j0')
|
||||
assert j0['x'] == 0.0
|
||||
@@ -284,6 +343,8 @@ class TestApi:
|
||||
nodes = get_nodes(p)
|
||||
assert len(nodes) == 0
|
||||
|
||||
assert get_junction(p, 'j0') == {}
|
||||
|
||||
add_junction(p, ChangeSet({'id': 'j1', 'x': 0.0, 'y': 10.0, 'elevation': 20.0}))
|
||||
add_junction(p, ChangeSet({'id': 'j2', 'x': 0.0, 'y': 10.0, 'elevation': 20.0}))
|
||||
add_junction(p, ChangeSet({'id': 'j3', 'x': 0.0, 'y': 10.0, 'elevation': 20.0}))
|
||||
@@ -455,6 +516,8 @@ class TestApi:
|
||||
p = 'test_reservoir'
|
||||
self.enter(p)
|
||||
|
||||
assert get_reservoir(p, 'r0') == {}
|
||||
|
||||
add_reservoir(p, ChangeSet({'id': 'r0', 'x': 0.0, 'y': 10.0, 'head': 20.0}))
|
||||
r0 = get_reservoir(p, 'r0')
|
||||
assert r0['x'] == 0.0
|
||||
@@ -491,6 +554,8 @@ class TestApi:
|
||||
nodes = get_nodes(p)
|
||||
assert len(nodes) == 0
|
||||
|
||||
assert get_reservoir(p, 'r0') == {}
|
||||
|
||||
add_reservoir(p, ChangeSet({'id': 'r1', 'x': 0.0, 'y': 10.0, 'head': 20.0}))
|
||||
add_reservoir(p, ChangeSet({'id': 'r2', 'x': 0.0, 'y': 10.0, 'head': 20.0}))
|
||||
add_reservoir(p, ChangeSet({'id': 'r3', 'x': 0.0, 'y': 10.0, 'head': 20.0}))
|
||||
@@ -638,6 +703,8 @@ class TestApi:
|
||||
p = 'test_tank'
|
||||
self.enter(p)
|
||||
|
||||
assert get_tank(p, 't0') == {}
|
||||
|
||||
add_tank(p, ChangeSet({'id': 't0', 'x': 0.0, 'y': 10.0, 'elevation': 20.0, 'init_level': 1.0, 'min_level': 0.0, 'max_level': 2.0, 'diameter': 10.0, 'min_vol': 100.0, 'vol_curve': None, 'overflow': OVERFLOW_NO}))
|
||||
t0 = get_tank(p, 't0')
|
||||
assert t0['x'] == 0.0
|
||||
@@ -698,6 +765,8 @@ class TestApi:
|
||||
nodes = get_nodes(p)
|
||||
assert len(nodes) == 0
|
||||
|
||||
assert get_tank(p, 't0') == {}
|
||||
|
||||
add_tank(p, ChangeSet({'id': 't1', 'x': 0.0, 'y': 10.0, 'elevation': 20.0, 'init_level': 1.0, 'min_level': 0.0, 'max_level': 2.0, 'diameter': 10.0, 'min_vol': 100.0, 'vol_curve': None, 'overflow': OVERFLOW_NO}))
|
||||
add_tank(p, ChangeSet({'id': 't2', 'x': 0.0, 'y': 10.0, 'elevation': 20.0, 'init_level': 1.0, 'min_level': 0.0, 'max_level': 2.0, 'diameter': 10.0, 'min_vol': 100.0, 'vol_curve': None, 'overflow': OVERFLOW_NO}))
|
||||
add_tank(p, ChangeSet({'id': 't3', 'x': 0.0, 'y': 10.0, 'elevation': 20.0, 'init_level': 1.0, 'min_level': 0.0, 'max_level': 2.0, 'diameter': 10.0, 'min_vol': 100.0, 'vol_curve': None, 'overflow': OVERFLOW_NO}))
|
||||
@@ -895,6 +964,8 @@ class TestApi:
|
||||
assert is_junction(p, 'j3')
|
||||
assert is_junction(p, 'j4')
|
||||
|
||||
assert get_pipe(p, 'p0') == {}
|
||||
|
||||
add_pipe(p, ChangeSet({'id': 'p0', 'node1': 'j1', 'node2': 'j2', 'length': 100.0, 'diameter': 10.0, 'roughness': 0.1, 'minor_loss': 0.5, 'status': PIPE_STATUS_OPEN }))
|
||||
p0 = get_pipe(p, 'p0')
|
||||
assert p0['node1'] == 'j1'
|
||||
@@ -947,6 +1018,8 @@ class TestApi:
|
||||
links = get_links(p)
|
||||
assert len(links) == 0
|
||||
|
||||
assert get_pipe(p, 'p0') == {}
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
@@ -1140,6 +1213,8 @@ class TestApi:
|
||||
assert is_junction(p, 'j3')
|
||||
assert is_junction(p, 'j4')
|
||||
|
||||
assert get_pump(p, 'p0') == {}
|
||||
|
||||
add_pump(p, ChangeSet({'id': 'p0', 'node1': 'j1', 'node2': 'j2', 'power': 0.0}))
|
||||
p0 = get_pump(p, 'p0')
|
||||
assert p0['node1'] == 'j1'
|
||||
@@ -1175,6 +1250,8 @@ class TestApi:
|
||||
links = get_links(p)
|
||||
assert len(links) == 0
|
||||
|
||||
assert get_pump(p, 'p0') == {}
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
@@ -1347,6 +1424,8 @@ class TestApi:
|
||||
assert is_junction(p, 'j3')
|
||||
assert is_junction(p, 'j4')
|
||||
|
||||
assert get_valve(p, 'v0') == {}
|
||||
|
||||
add_valve(p, ChangeSet({'id': 'v0', 'node1': 'j1', 'node2': 'j2', 'diameter': 10.0, 'v_type': VALVES_TYPE_FCV, 'setting': '0.1', 'minor_loss': 0.5 }))
|
||||
v0 = get_valve(p, 'v0')
|
||||
assert v0['node1'] == 'j1'
|
||||
@@ -1394,6 +1473,8 @@ class TestApi:
|
||||
links = get_links(p)
|
||||
assert len(links) == 0
|
||||
|
||||
assert get_valve(p, 'v0') == {}
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
@@ -1826,6 +1907,8 @@ class TestApi:
|
||||
|
||||
assert is_pattern(p, 'p0') == False
|
||||
|
||||
assert get_pattern(p, 'p0') == {}
|
||||
|
||||
add_pattern(p, ChangeSet({'id' : 'p0', 'factors': [1.0, 2.0, 3.0]}))
|
||||
|
||||
assert is_pattern(p, 'p0')
|
||||
@@ -1850,6 +1933,8 @@ class TestApi:
|
||||
delete_pattern(p, ChangeSet({'id' : 'p0'}))
|
||||
assert is_pattern(p, 'p0') == False
|
||||
|
||||
assert get_pattern(p, 'p0') == {}
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
@@ -1983,6 +2068,8 @@ class TestApi:
|
||||
|
||||
assert is_curve(p, 'c0') == False
|
||||
|
||||
assert get_curve(p, 'c0') == {}
|
||||
|
||||
add_curve(p, ChangeSet({'id' : 'c0', 'c_type' : CURVE_TYPE_PUMP, 'coords': [{'x': 1.0, 'y': 2.0}, {'x': 2.0, 'y': 1.0}]}))
|
||||
|
||||
assert is_curve(p, 'c0')
|
||||
@@ -2019,6 +2106,8 @@ class TestApi:
|
||||
|
||||
assert is_curve(p, 'c0') == False
|
||||
|
||||
assert get_curve(p, 'c0') == {}
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
@@ -3012,6 +3101,8 @@ class TestApi:
|
||||
|
||||
add_tank(p, ChangeSet({'id': 't0', 'x': 0.0, 'y': 10.0, 'elevation': 20.0, 'init_level': 1.0, 'min_level': 0.0, 'max_level': 2.0, 'diameter': 10.0, 'min_vol': 100.0, 'vol_curve': None, 'overflow': OVERFLOW_NO}))
|
||||
|
||||
assert get_mixing(p, 't0') == {}
|
||||
|
||||
add_mixing(p, ChangeSet({'tank': 't0', 'model': MIXING_MODEL_MIXED, 'value': 10.0}))
|
||||
m = get_mixing(p,'t0')
|
||||
assert m['tank'] == 't0'
|
||||
@@ -3032,6 +3123,8 @@ class TestApi:
|
||||
|
||||
delete_mixing(p, ChangeSet({'tank': 't0'}))
|
||||
|
||||
assert get_mixing(p, 't0') == {}
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user