Add curve api and test
This commit is contained in:
@@ -1313,7 +1313,7 @@ class TestApi:
|
||||
|
||||
|
||||
def test_pattern(self):
|
||||
p = 'test_demand'
|
||||
p = 'test_pattern'
|
||||
self.enter(p)
|
||||
|
||||
assert is_pattern(p, 'p0') == False
|
||||
@@ -1356,6 +1356,65 @@ class TestApi:
|
||||
self.leave(p)
|
||||
|
||||
|
||||
def test_curve(self):
|
||||
p = 'test_curve'
|
||||
self.enter(p)
|
||||
|
||||
assert is_curve(p, 'c0') == False
|
||||
c0 = get_curve(p, 'c0')
|
||||
assert c0['id'] == 'c0'
|
||||
assert c0['coords'] == []
|
||||
|
||||
set_curve(p, ChangeSet({'id' : 'c0', 'coords': [{'x': 1.0, 'y': 2.0}, {'x': 2.0, 'y': 1.0}]}))
|
||||
|
||||
assert is_curve(p, 'c0')
|
||||
c0 = get_curve(p, 'c0')
|
||||
assert c0['id'] == 'c0'
|
||||
xys = c0['coords']
|
||||
assert len(xys) == 2
|
||||
assert xys[0]['x'] == 1.0
|
||||
assert xys[0]['y'] == 2.0
|
||||
assert xys[1]['x'] == 2.0
|
||||
assert xys[1]['y'] == 1.0
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
def test_curve_op(self):
|
||||
p = 'test_curve_op'
|
||||
self.enter(p)
|
||||
|
||||
cs = set_curve(p, ChangeSet({'id' : 'c0', 'coords': [{'x': 1.0, 'y': 2.0}, {'x': 2.0, 'y': 1.0}]})).operations[0]
|
||||
assert cs['operation'] == API_UPDATE
|
||||
assert cs['type'] == CURVE
|
||||
assert cs['id'] == 'c0'
|
||||
xys = cs['coords']
|
||||
assert len(xys) == 2
|
||||
assert xys[0]['x'] == 1.0
|
||||
assert xys[0]['y'] == 2.0
|
||||
assert xys[1]['x'] == 2.0
|
||||
assert xys[1]['y'] == 1.0
|
||||
|
||||
cs = execute_undo(p).operations[0]
|
||||
assert cs['operation'] == API_UPDATE
|
||||
assert cs['type'] == CURVE
|
||||
assert cs['id'] == 'c0'
|
||||
assert cs['coords'] == []
|
||||
|
||||
cs = execute_redo(p).operations[0]
|
||||
assert cs['operation'] == API_UPDATE
|
||||
assert cs['type'] == CURVE
|
||||
assert cs['id'] == 'c0'
|
||||
xys = cs['coords']
|
||||
assert len(xys) == 2
|
||||
assert xys[0]['x'] == 1.0
|
||||
assert xys[0]['y'] == 2.0
|
||||
assert xys[1]['x'] == 2.0
|
||||
assert xys[1]['y'] == 1.0
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
def test_snapshot(self):
|
||||
p = "test_snapshot"
|
||||
self.enter(p)
|
||||
|
||||
Reference in New Issue
Block a user