Support database region
This commit is contained in:
@@ -5564,6 +5564,89 @@ class TestApi:
|
||||
self.leave(p)
|
||||
|
||||
|
||||
# 33 region
|
||||
|
||||
|
||||
def test_region(self):
|
||||
p = 'test_region'
|
||||
self.enter(p)
|
||||
|
||||
r = get_region(p, 'r')
|
||||
assert r == {}
|
||||
|
||||
add_region(p, ChangeSet({'id': 'r', 'boundary': [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 0.0)]}))
|
||||
r = get_region(p, 'r')
|
||||
assert r == { 'id': 'r', 'boundary': [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 0.0)] }
|
||||
|
||||
set_region(p, ChangeSet({'id': 'r', 'boundary': [(0.0, 0.0), (1.0, 0.0), (1.0, 2.0), (0.0, 0.0)]}))
|
||||
r = get_region(p, 'r')
|
||||
assert r == { 'id': 'r', 'boundary': [(0.0, 0.0), (1.0, 0.0), (1.0, 2.0), (0.0, 0.0)] }
|
||||
|
||||
delete_region(p, ChangeSet({'id': 'r'}))
|
||||
r = get_region(p, 'r')
|
||||
assert r == {}
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
def test_region_op(self):
|
||||
p = 'test_region_op'
|
||||
self.enter(p)
|
||||
|
||||
cs = add_region(p, ChangeSet({'id': 'r', 'boundary': [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 0.0)]})).operations[0]
|
||||
assert cs['operation'] == API_ADD
|
||||
assert cs['type'] == 'region'
|
||||
assert cs['id'] == 'r'
|
||||
assert cs['boundary'] == [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 0.0)]
|
||||
|
||||
cs = execute_undo(p).operations[0]
|
||||
assert cs['operation'] == API_DELETE
|
||||
assert cs['type'] == 'region'
|
||||
assert cs['id'] == 'r'
|
||||
|
||||
cs = execute_redo(p).operations[0]
|
||||
assert cs['operation'] == API_ADD
|
||||
assert cs['type'] == 'region'
|
||||
assert cs['id'] == 'r'
|
||||
assert cs['boundary'] == [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 0.0)]
|
||||
|
||||
cs = set_region(p, ChangeSet({'id': 'r', 'boundary': [(0.0, 0.0), (1.0, 0.0), (1.0, 2.0), (0.0, 0.0)]})).operations[0]
|
||||
assert cs['operation'] == API_UPDATE
|
||||
assert cs['type'] == 'region'
|
||||
assert cs['id'] == 'r'
|
||||
assert cs['boundary'] == [(0.0, 0.0), (1.0, 0.0), (1.0, 2.0), (0.0, 0.0)]
|
||||
|
||||
cs = execute_undo(p).operations[0]
|
||||
assert cs['operation'] == API_UPDATE
|
||||
assert cs['type'] == 'region'
|
||||
assert cs['id'] == 'r'
|
||||
assert cs['boundary'] == [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 0.0)]
|
||||
|
||||
cs = execute_redo(p).operations[0]
|
||||
assert cs['operation'] == API_UPDATE
|
||||
assert cs['type'] == 'region'
|
||||
assert cs['id'] == 'r'
|
||||
assert cs['boundary'] == [(0.0, 0.0), (1.0, 0.0), (1.0, 2.0), (0.0, 0.0)]
|
||||
|
||||
cs = delete_region(p, ChangeSet({'id': 'r'})).operations[0]
|
||||
assert cs['operation'] == API_DELETE
|
||||
assert cs['type'] == 'region'
|
||||
assert cs['id'] == 'r'
|
||||
|
||||
cs = execute_undo(p).operations[0]
|
||||
assert cs['operation'] == API_ADD
|
||||
assert cs['type'] == 'region'
|
||||
assert cs['id'] == 'r'
|
||||
assert cs['boundary'] == [(0.0, 0.0), (1.0, 0.0), (1.0, 2.0), (0.0, 0.0)]
|
||||
|
||||
cs = execute_redo(p).operations[0]
|
||||
assert cs['operation'] == API_DELETE
|
||||
assert cs['type'] == 'region'
|
||||
assert cs['id'] == 'r'
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
# 37 virtual_district
|
||||
|
||||
def test_virtual_district(self):
|
||||
|
||||
Reference in New Issue
Block a user