Add pattern api and test
This commit is contained in:
@@ -1312,6 +1312,50 @@ class TestApi:
|
||||
self.leave(p)
|
||||
|
||||
|
||||
def test_pattern(self):
|
||||
p = 'test_demand'
|
||||
self.enter(p)
|
||||
|
||||
assert is_pattern(p, 'p0') == False
|
||||
p0 = get_pattern(p, 'p0')
|
||||
assert p0['id'] == 'p0'
|
||||
assert p0['factors'] == []
|
||||
|
||||
set_pattern(p, ChangeSet({'id' : 'p0', 'factors': [1.0, 2.0, 3.0]}))
|
||||
|
||||
assert is_pattern(p, 'p0')
|
||||
p0 = get_pattern(p, 'p0')
|
||||
assert p0['id'] == 'p0'
|
||||
assert p0['factors'] == [1.0, 2.0, 3.0]
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
def test_pattern_op(self):
|
||||
p = 'test_pattern_op'
|
||||
self.enter(p)
|
||||
|
||||
cs = set_pattern(p, ChangeSet({'id' : 'p0', 'factors': [1.0, 2.0, 3.0]})).operations[0]
|
||||
assert cs['operation'] == API_UPDATE
|
||||
assert cs['type'] == PATTERN
|
||||
assert cs['id'] == 'p0'
|
||||
assert cs['factors'] == [1.0, 2.0, 3.0]
|
||||
|
||||
cs = execute_undo(p).operations[0]
|
||||
assert cs['operation'] == API_UPDATE
|
||||
assert cs['type'] == PATTERN
|
||||
assert cs['id'] == 'p0'
|
||||
assert cs['factors'] == []
|
||||
|
||||
cs = execute_redo(p).operations[0]
|
||||
assert cs['operation'] == API_UPDATE
|
||||
assert cs['type'] == PATTERN
|
||||
assert cs['id'] == 'p0'
|
||||
assert cs['factors'] == [1.0, 2.0, 3.0]
|
||||
|
||||
self.leave(p)
|
||||
|
||||
|
||||
def test_snapshot(self):
|
||||
p = "test_snapshot"
|
||||
self.enter(p)
|
||||
|
||||
Reference in New Issue
Block a user