Add title & junction test case
This commit is contained in:
@@ -30,5 +30,5 @@ def update(name: str, type: str, table: str, id_key: str, id_value: str, key: st
|
|||||||
add_operation(name, redo, undo)
|
add_operation(name, redo, undo)
|
||||||
|
|
||||||
change = ChangeSet()
|
change = ChangeSet()
|
||||||
change.update(type, id, key, key_type, value)
|
change.update(type, id_value, key, key_type, value)
|
||||||
return change
|
return change
|
||||||
|
|||||||
@@ -12,14 +12,78 @@ class TestApi:
|
|||||||
create_project(p)
|
create_project(p)
|
||||||
open_project(p)
|
open_project(p)
|
||||||
|
|
||||||
def leave(self, project):
|
def leave(self, p):
|
||||||
close_project(p)
|
close_project(p)
|
||||||
delete_project(p)
|
delete_project(p)
|
||||||
|
|
||||||
def test_title(self):
|
def test_title(self):
|
||||||
pass
|
p = "test_title"
|
||||||
|
self.enter(p)
|
||||||
|
|
||||||
|
assert get_title(p) == ""
|
||||||
|
|
||||||
|
set_title(p, "title")
|
||||||
|
assert get_title(p) == "title"
|
||||||
|
|
||||||
|
set_title(p, "test")
|
||||||
|
assert get_title(p) == "test"
|
||||||
|
|
||||||
|
self.leave(p)
|
||||||
|
|
||||||
def test_junction(self):
|
def test_junction(self):
|
||||||
|
p = "test_junction"
|
||||||
|
self.enter(p)
|
||||||
|
|
||||||
|
change_set = add_junction(p, "j0", 0.0, 10.0, 20.0)
|
||||||
|
assert len(change_set.added) == 1
|
||||||
|
assert change_set.added[0]['type'] == 'junction'
|
||||||
|
assert change_set.added[0]['id'] == "j0"
|
||||||
|
coord = get_junction_coord(p, 'j0')
|
||||||
|
assert coord['x'] == 0.0
|
||||||
|
assert coord['y'] == 10.0
|
||||||
|
z = get_junction_elevation(p, 'j0')
|
||||||
|
assert z == 20.0
|
||||||
|
|
||||||
|
assert get_junction_demand(p, 'j') == None
|
||||||
|
assert get_junction_demand(p, 'j0') == "NULL"
|
||||||
|
change_set = set_junction_demand(p, 'j0', 100.0)
|
||||||
|
assert len(change_set.updated) == 1
|
||||||
|
assert change_set.updated[0]['type'] == 'junction'
|
||||||
|
assert change_set.updated[0]['id'] == 'j0'
|
||||||
|
assert change_set.updated[0]['property'] == 'demand'
|
||||||
|
assert change_set.updated[0]['property_type'] == 'float'
|
||||||
|
assert change_set.updated[0]['property_value'] == str(100.0)
|
||||||
|
assert get_junction_demand(p, 'j0') == 100.0
|
||||||
|
|
||||||
|
change_set = add_junction(p, "j1", 0.0, 10.0, 20.0)
|
||||||
|
assert len(change_set.added) == 1
|
||||||
|
assert change_set.added[0]['type'] == 'junction'
|
||||||
|
assert change_set.added[0]['id'] == "j1"
|
||||||
|
|
||||||
|
nodes = get_nodes(p)
|
||||||
|
assert len(nodes) == 2
|
||||||
|
assert nodes[0] == "j0"
|
||||||
|
assert nodes[1] == "j1"
|
||||||
|
|
||||||
|
change_set = delete_junction(p, 'j1')
|
||||||
|
assert len(change_set.deleted) == 1
|
||||||
|
assert change_set.deleted[0]['type'] == 'junction'
|
||||||
|
assert change_set.deleted[0]['id'] == "j1"
|
||||||
|
|
||||||
|
nodes = get_nodes(p)
|
||||||
|
assert len(nodes) == 1
|
||||||
|
assert nodes[0] == "j0"
|
||||||
|
|
||||||
|
change_set = delete_junction(p, 'j0')
|
||||||
|
assert len(change_set.deleted) == 1
|
||||||
|
assert change_set.deleted[0]['type'] == 'junction'
|
||||||
|
assert change_set.deleted[0]['id'] == "j0"
|
||||||
|
|
||||||
|
nodes = get_nodes(p)
|
||||||
|
assert len(nodes) == 0
|
||||||
|
|
||||||
|
self.leave(p)
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_reservoir(self):
|
def test_reservoir(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user