Refine pump schema
This commit is contained in:
@@ -165,7 +165,7 @@ class TestApi:
|
||||
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}))
|
||||
add_pipe(p, ChangeSet({'id': 'p1', 'node1': 'j1', 'node2': 'j2', 'length': 100.0, 'diameter': 10.0, 'roughness': 0.1, 'minor_loss': 0.5, 'status': PIPE_STATUS_OPEN }))
|
||||
add_pump(p, ChangeSet({'id': 'p2', 'node1': 'j1', 'node2': 'j2'}))
|
||||
add_pump(p, ChangeSet({'id': 'p2', 'node1': 'j1', 'node2': 'j2', 'power': 0.0}))
|
||||
add_valve(p, ChangeSet({'id': 'v1', 'node1': 'j2', 'node2': 'j3', 'diameter': 10.0, 'v_type': VALVES_TYPE_FCV, 'setting': 0.1, 'minor_loss': 0.5 }))
|
||||
assert get_junction(p, 'j1')['links'] == ['p1', 'p2']
|
||||
assert get_junction(p, 'j2')['links'] == ['p1', 'p2', 'v1']
|
||||
@@ -322,7 +322,7 @@ class TestApi:
|
||||
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}))
|
||||
add_pipe(p, ChangeSet({'id': 'p1', 'node1': 'r1', 'node2': 'r2', 'length': 100.0, 'diameter': 10.0, 'roughness': 0.1, 'minor_loss': 0.5, 'status': PIPE_STATUS_OPEN }))
|
||||
add_pump(p, ChangeSet({'id': 'p2', 'node1': 'r1', 'node2': 'r2'}))
|
||||
add_pump(p, ChangeSet({'id': 'p2', 'node1': 'r1', 'node2': 'r2', 'power': 0.0}))
|
||||
add_valve(p, ChangeSet({'id': 'v1', 'node1': 'r2', 'node2': 'r3', 'diameter': 10.0, 'v_type': VALVES_TYPE_FCV, 'setting': 0.1, 'minor_loss': 0.5 }))
|
||||
assert get_reservoir(p, 'r1')['links'] == ['p1', 'p2']
|
||||
assert get_reservoir(p, 'r2')['links'] == ['p1', 'p2', 'v1']
|
||||
@@ -497,7 +497,7 @@ class TestApi:
|
||||
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}))
|
||||
add_pipe(p, ChangeSet({'id': 'p1', 'node1': 't1', 'node2': 't2', 'length': 100.0, 'diameter': 10.0, 'roughness': 0.1, 'minor_loss': 0.5, 'status': PIPE_STATUS_OPEN }))
|
||||
add_pump(p, ChangeSet({'id': 'p2', 'node1': 't1', 'node2': 't2'}))
|
||||
add_pump(p, ChangeSet({'id': 'p2', 'node1': 't1', 'node2': 't2', 'power': 0.0}))
|
||||
add_valve(p, ChangeSet({'id': 'v1', 'node1': 't2', 'node2': 't3', 'diameter': 10.0, 'v_type': VALVES_TYPE_FCV, 'setting': 0.1, 'minor_loss': 0.5 }))
|
||||
assert get_tank(p, 't1')['links'] == ['p1', 'p2']
|
||||
assert get_tank(p, 't2')['links'] == ['p1', 'p2', 'v1']
|
||||
@@ -846,17 +846,25 @@ class TestApi:
|
||||
assert is_junction(p, 'j3')
|
||||
assert is_junction(p, 'j4')
|
||||
|
||||
add_pump(p, ChangeSet({'id': 'p0', 'node1': 'j1', 'node2': 'j2'}))
|
||||
add_pump(p, ChangeSet({'id': 'p0', 'node1': 'j1', 'node2': 'j2', 'power': 0.0}))
|
||||
p0 = get_pump(p, 'p0')
|
||||
assert p0['node1'] == 'j1'
|
||||
assert p0['node2'] == 'j2'
|
||||
assert p0['power'] == 0.0
|
||||
assert p0['head'] == None
|
||||
assert p0['speed'] == None
|
||||
assert p0['pattern'] == None
|
||||
|
||||
set_pump(p, ChangeSet({'id': 'p0', 'node1': 'j3', 'node2': 'j4'}))
|
||||
p0 = get_pump(p, 'p0')
|
||||
assert p0['node1'] == 'j3'
|
||||
assert p0['node2'] == 'j4'
|
||||
|
||||
add_pump(p, ChangeSet({'id': 'p1', 'node1': 'j1', 'node2': 'j2'}))
|
||||
set_pump(p, ChangeSet({'id': 'p0', 'power': 100.0}))
|
||||
p0 = get_pump(p, 'p0')
|
||||
assert p0['power'] == 100.0
|
||||
|
||||
add_pump(p, ChangeSet({'id': 'p1', 'node1': 'j1', 'node2': 'j2', 'power': 0.0}))
|
||||
links = get_links(p)
|
||||
assert len(links) == 2
|
||||
assert links[0] == 'p0'
|
||||
@@ -889,12 +897,13 @@ class TestApi:
|
||||
assert is_junction(p, 'j3')
|
||||
assert is_junction(p, 'j4')
|
||||
|
||||
cs = add_pump(p, ChangeSet({'id': 'p0', 'node1': 'j1', 'node2': 'j2'})).operations[0]
|
||||
cs = add_pump(p, ChangeSet({'id': 'p0', 'node1': 'j1', 'node2': 'j2', 'power': 0.0})).operations[0]
|
||||
assert cs['operation'] == 'add'
|
||||
assert cs['type'] == PUMP
|
||||
assert cs['id'] == 'p0'
|
||||
assert cs['node1'] == 'j1'
|
||||
assert cs['node2'] == 'j2'
|
||||
assert cs['power'] == 0.0
|
||||
|
||||
cs = execute_undo(p).operations[0]
|
||||
assert cs['operation'] == 'delete'
|
||||
@@ -919,7 +928,7 @@ class TestApi:
|
||||
links = get_links(p)
|
||||
assert len(links) == 0
|
||||
|
||||
add_pump(p, ChangeSet({'id': 'p0', 'node1': 'j1', 'node2': 'j2'}))
|
||||
add_pump(p, ChangeSet({'id': 'p0', 'node1': 'j1', 'node2': 'j2', 'power': 0.0}))
|
||||
|
||||
links = get_links(p)
|
||||
assert len(links) == 1
|
||||
@@ -968,6 +977,18 @@ class TestApi:
|
||||
assert cs['node1'] == 'j1'
|
||||
assert cs['node2'] == 'j2'
|
||||
|
||||
cs = set_pump(p, ChangeSet({'id': 'p0', 'power': 100.0})).operations[0]
|
||||
assert cs['operation'] == 'update'
|
||||
assert cs['type'] == PUMP
|
||||
assert cs['id'] == 'p0'
|
||||
assert cs['power'] == 100.0
|
||||
|
||||
cs = execute_undo(p).operations[0]
|
||||
assert cs['operation'] == 'update'
|
||||
assert cs['type'] == PUMP
|
||||
assert cs['id'] == 'p0'
|
||||
assert cs['power'] == 0.0
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user