Fix snapshot api and test
This commit is contained in:
@@ -180,12 +180,12 @@ def take_snapshot_for_operation(name: str, operation: int, tag: str) -> None:
|
||||
write(name, f"insert into snapshot_operation (id, tag) values ({operation}, '{tag}')")
|
||||
|
||||
|
||||
def take_snapshot_for_current_operation(name: str, tag: str) -> int | None:
|
||||
def take_snapshot_for_current_operation(name: str, tag: str) -> None:
|
||||
take_snapshot_for_operation(name, get_current_operation(name), tag)
|
||||
|
||||
|
||||
# deprecated ! use take_snapshot_for_current_operation instead
|
||||
def take_snapshot(name: str, tag: str) -> int | None:
|
||||
def take_snapshot(name: str, tag: str) -> None:
|
||||
take_snapshot_for_current_operation(name, tag)
|
||||
|
||||
|
||||
|
||||
@@ -77,18 +77,26 @@ class TestApi:
|
||||
add_junction(p, ChangeSet({'id': 'j3', 'x': 0.0, 'y': 10.0, 'elevation': 20.0}))
|
||||
add_junction(p, ChangeSet({'id': 'j4', 'x': 0.0, 'y': 10.0, 'elevation': 20.0}))
|
||||
|
||||
client_op = get_current_operation(p)
|
||||
assert client_op == 4
|
||||
assert take_snapshot(p, 'x') == 4
|
||||
op_4 = get_current_operation(p)
|
||||
assert op_4 == 4
|
||||
take_snapshot(p, 'x')
|
||||
assert get_snapshot_by_operation(p, 4) == 'x'
|
||||
assert get_operation_by_snapshot(p, 'x') == 4
|
||||
update_snapshot_for_current_operation(p, 'y')
|
||||
assert get_snapshot_by_operation(p, 4) == 'y'
|
||||
|
||||
execute_undo(p)
|
||||
execute_undo(p)
|
||||
add_junction(p, ChangeSet({'id': 'j5', 'x': 0.0, 'y': 10.0, 'elevation': 20.0}))
|
||||
add_junction(p, ChangeSet({'id': 'j6', 'x': 0.0, 'y': 10.0, 'elevation': 20.0}))
|
||||
|
||||
assert take_snapshot(p, 'xx') == 6
|
||||
op_6 = get_current_operation(p)
|
||||
assert op_6 == 6
|
||||
take_snapshot(p, 'xx')
|
||||
assert get_snapshot_by_operation(p, 6) == 'xx'
|
||||
assert get_operation_by_snapshot(p, 'xx') == 6
|
||||
|
||||
cs = sync_with_server(p, client_op).operations
|
||||
cs = sync_with_server(p, op_4).operations
|
||||
cs[0]['operation'] = API_DELETE
|
||||
cs[0]['id'] = 'j4'
|
||||
cs[1]['operation'] = API_DELETE
|
||||
@@ -98,7 +106,7 @@ class TestApi:
|
||||
cs[3]['operation'] = API_ADD
|
||||
cs[3]['id'] = 'j6'
|
||||
|
||||
cs = pick_snapshot(p, 'x').operations
|
||||
cs = pick_snapshot(p, 'y').operations
|
||||
cs[0]['operation'] = 'delete'
|
||||
cs[0]['id'] = 'j6'
|
||||
cs[1]['operation'] = 'delete'
|
||||
|
||||
Reference in New Issue
Block a user