Support database region

This commit is contained in:
WQY\qiong
2023-04-29 17:51:34 +08:00
parent a3e8f693d9
commit d66087225f
5 changed files with 224 additions and 2 deletions

View File

@@ -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):