Add transaction demo
This commit is contained in:
43
new_demo.py
43
new_demo.py
@@ -1,5 +1,6 @@
|
||||
from tjnetwork_new import *
|
||||
|
||||
|
||||
def demo_snapshot():
|
||||
p = "demo_snapshot"
|
||||
|
||||
@@ -13,8 +14,8 @@ def demo_snapshot():
|
||||
open_project(p)
|
||||
|
||||
add_junction(p, 'j-1', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-2', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-3', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-2', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-3', 10.0, 20.0, 30.0)
|
||||
add_junction(p, 'j-4', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "1-2-3-4")
|
||||
|
||||
@@ -35,6 +36,41 @@ def demo_snapshot():
|
||||
# delete_project(p)
|
||||
|
||||
|
||||
def demo_transaction():
|
||||
p = "demo_transaction"
|
||||
|
||||
if is_project_open(p):
|
||||
close_project(p)
|
||||
|
||||
if have_project(p):
|
||||
delete_project(p)
|
||||
|
||||
create_project(p)
|
||||
open_project(p)
|
||||
|
||||
add_junction(p, 'j-1', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "1")
|
||||
add_junction(p, 'j-2', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "2")
|
||||
|
||||
start_transaction(p)
|
||||
|
||||
add_junction(p, 'j-3', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "3")
|
||||
add_junction(p, 'j-4', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "4")
|
||||
|
||||
abort_transaction(p)
|
||||
|
||||
print(have_snapshot(p, "1"))
|
||||
print(have_snapshot(p, "2"))
|
||||
print(have_snapshot(p, "3"))
|
||||
print(have_snapshot(p, "4"))
|
||||
|
||||
close_project(p)
|
||||
# delete_project(p)
|
||||
|
||||
|
||||
def demo_1_title():
|
||||
p = "demo_1_title"
|
||||
|
||||
@@ -121,7 +157,8 @@ def demo_2_junctions():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo_snapshot()
|
||||
# demo_snapshot()
|
||||
demo_transaction()
|
||||
# demo_1_title()
|
||||
# demo_2_junctions()
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user