Support compress batch commands as one command
This commit is contained in:
@@ -1834,5 +1834,44 @@ class TestApi:
|
||||
self.leave(p)
|
||||
|
||||
|
||||
def test_batch_command(self):
|
||||
p = 'test_batch_command'
|
||||
self.enter(p)
|
||||
|
||||
cs = ChangeSet()
|
||||
cs.add({'type': JUNCTION, 'id': 'j1', 'x': 0.0, 'y': 10.0, 'elevation': 20.0})
|
||||
cs.add({'type': JUNCTION, 'id': 'j2', 'x': 0.0, 'y': 10.0, 'elevation': 20.0})
|
||||
cs.add({'type': JUNCTION, 'id': 'j2', 'x': 0.0, 'y': 10.0, 'elevation': 20.0}) # fail
|
||||
|
||||
cs = execute_batch_command(p, cs)
|
||||
assert len(cs.operations) == 0
|
||||
|
||||
assert get_current_operation(p) == 0
|
||||
|
||||
cs = ChangeSet()
|
||||
cs.add({'type': JUNCTION, 'id': 'j1', 'x': 0.0, 'y': 10.0, 'elevation': 20.0})
|
||||
cs.add({'type': JUNCTION, 'id': 'j2', 'x': 0.0, 'y': 10.0, 'elevation': 20.0})
|
||||
|
||||
cs = execute_batch_command(p, cs)
|
||||
|
||||
assert get_current_operation(p) == 1
|
||||
|
||||
cs = ChangeSet()
|
||||
cs.delete({'type': JUNCTION, 'id': 'j1'})
|
||||
cs.delete({'type': JUNCTION, 'id': 'j2'})
|
||||
|
||||
cs = execute_batch_command(p, cs)
|
||||
|
||||
assert get_current_operation(p) == 2
|
||||
|
||||
cs = execute_undo(p)
|
||||
assert get_current_operation(p) == 1
|
||||
|
||||
cs = execute_undo(p)
|
||||
assert get_current_operation(p) == 0
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pytest.main()
|
||||
|
||||
Reference in New Issue
Block a user