Let set_demand be a batch command
This commit is contained in:
@@ -1323,8 +1323,12 @@ class TestApi:
|
||||
assert ds[1]['pattern'] == None
|
||||
assert ds[1]['category'] == None
|
||||
|
||||
assert get_junction(p, 'j1')['demand'] == 10.0
|
||||
|
||||
set_demand(p, ChangeSet({'junction': 'j1', 'demands': []}))
|
||||
|
||||
assert get_junction(p, 'j1')['demand'] == None
|
||||
|
||||
d = get_demand(p, 'j1')
|
||||
assert d['junction'] == 'j1'
|
||||
assert d['demands'] == []
|
||||
@@ -1339,8 +1343,9 @@ class TestApi:
|
||||
add_junction(p, ChangeSet({'id': 'j1', 'x': 0.0, 'y': 10.0, 'elevation': 20.0}))
|
||||
assert is_junction(p, 'j1')
|
||||
|
||||
cs = set_demand(p, ChangeSet({'junction': 'j1', 'demands': [{'demand': 10.0, 'pattern': None, 'category': 'x'},
|
||||
{'demand': 20.0, 'pattern': None, 'category': None}]})).operations[0]
|
||||
result = set_demand(p, ChangeSet({'junction': 'j1', 'demands': [{'demand': 10.0, 'pattern': None, 'category': 'x'},
|
||||
{'demand': 20.0, 'pattern': None, 'category': None}]}))
|
||||
cs = result.operations[0]
|
||||
assert cs['operation'] == API_UPDATE
|
||||
assert cs['type'] == 'demand'
|
||||
assert cs['junction'] == 'j1'
|
||||
@@ -1352,14 +1357,26 @@ class TestApi:
|
||||
assert ds[1]['demand'] == 20.0
|
||||
assert ds[1]['pattern'] == None
|
||||
assert ds[1]['category'] == None
|
||||
cs = result.operations[1]
|
||||
assert cs['operation'] == API_UPDATE
|
||||
assert cs['type'] == JUNCTION
|
||||
assert cs['id'] == 'j1'
|
||||
assert cs['demand'] == 10.0
|
||||
|
||||
cs = execute_undo(p).operations[0]
|
||||
result = execute_undo(p)
|
||||
cs = result.operations[0]
|
||||
assert cs['operation'] == API_UPDATE
|
||||
assert cs['type'] == JUNCTION
|
||||
assert cs['id'] == 'j1'
|
||||
assert cs['demand'] == None
|
||||
cs = result.operations[1]
|
||||
assert cs['operation'] == API_UPDATE
|
||||
assert cs['type'] == 'demand'
|
||||
assert cs['junction'] == 'j1'
|
||||
assert len(cs['demands']) == 0
|
||||
|
||||
cs = execute_redo(p).operations[0]
|
||||
result = execute_redo(p)
|
||||
cs = result.operations[0]
|
||||
assert cs['operation'] == API_UPDATE
|
||||
assert cs['type'] == 'demand'
|
||||
assert cs['junction'] == 'j1'
|
||||
@@ -1371,6 +1388,11 @@ class TestApi:
|
||||
assert ds[1]['demand'] == 20.0
|
||||
assert ds[1]['pattern'] == None
|
||||
assert ds[1]['category'] == None
|
||||
cs = result.operations[1]
|
||||
assert cs['operation'] == API_UPDATE
|
||||
assert cs['type'] == JUNCTION
|
||||
assert cs['id'] == 'j1'
|
||||
assert cs['demand'] == 10.0
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user