Add test for unset

This commit is contained in:
WQY\qiong
2022-10-22 13:43:14 +08:00
parent 85b879e2c4
commit 40e97fd166

View File

@@ -1181,6 +1181,10 @@ class TestApi:
add_junction(p, ChangeSet({'id': 'j1', 'x': 0.0, 'y': 10.0, 'elevation': 20.0}))
assert is_junction(p, 'j1')
d = get_demand(p, 'j1')
assert d['junction'] == 'j1'
assert d['demands'] == []
set_demand(p, ChangeSet({'junction': 'j1', 'demands': [{'demand': 10.0, 'pattern': None, 'category': 'x'},
{'demand': 20.0, 'pattern': None, 'category': None}]}))
d = get_demand(p, 'j1')
@@ -1194,6 +1198,11 @@ class TestApi:
assert ds[1]['pattern'] == None
assert ds[1]['category'] == None
set_demand(p, ChangeSet({'junction': 'j1', 'demands': []}))
d = get_demand(p, 'j1')
assert d['junction'] == 'j1'
assert d['demands'] == []
self.leave(p)
@@ -1263,6 +1272,12 @@ class TestApi:
assert s['status'] == LINK_STATUS_OPEN
assert s['setting'] == 10.0
set_status(p, ChangeSet({'link': 'p0', 'status': None, 'setting': None}))
s = get_status(p, 'p0')
assert s['link'] == 'p0'
assert s['status'] == None
assert s['setting'] == None
self.leave(p)
@@ -1328,6 +1343,13 @@ class TestApi:
assert p0['id'] == 'p0'
assert p0['factors'] == [1.0, 2.0, 3.0]
set_pattern(p, ChangeSet({'id' : 'p0', 'factors': []}))
assert is_pattern(p, 'p0') == False
p0 = get_pattern(p, 'p0')
assert p0['id'] == 'p0'
assert p0['factors'] == []
self.leave(p)
@@ -1377,6 +1399,13 @@ class TestApi:
assert xys[1]['x'] == 2.0
assert xys[1]['y'] == 1.0
set_curve(p, ChangeSet({'id' : 'c0', 'coords': []}))
assert is_curve(p, 'c0') == False
c0 = get_curve(p, 'c0')
assert c0['id'] == 'c0'
assert c0['coords'] == []
self.leave(p)