Checking many operations together.
()
| 93 | |
| 94 | |
| 95 | def demo_manyops(): |
| 96 | """Checking many operations together.""" |
| 97 | |
| 98 | # Initialize the data base with some nodes |
| 99 | fileh = setUp("undo-redo-manyops.h5") |
| 100 | |
| 101 | # Create an array |
| 102 | fileh.create_array(fileh.root, "anarray3", [3], "Array title 3") |
| 103 | # Create a group |
| 104 | fileh.create_group(fileh.root, "agroup3", "Group title 3") |
| 105 | # /anarray => /agroup/agroup3/ |
| 106 | new_node = fileh.copy_node("/anarray3", "/agroup/agroup2") |
| 107 | new_node = fileh.copy_children("/agroup", "/agroup3", recursive=1) |
| 108 | # rename anarray |
| 109 | fileh.rename_node("/anarray", "anarray4") |
| 110 | # Move anarray |
| 111 | new_node = fileh.copy_node("/anarray3", "/agroup") |
| 112 | # Remove anarray4 |
| 113 | fileh.remove_node("/anarray4") |
| 114 | # Undo the actions |
| 115 | fileh.undo() |
| 116 | assert "/anarray4" not in fileh |
| 117 | assert "/anarray3" not in fileh |
| 118 | assert "/agroup/agroup2/anarray3" not in fileh |
| 119 | assert "/agroup3" not in fileh |
| 120 | assert "/anarray4" not in fileh |
| 121 | assert "/anarray" in fileh |
| 122 | |
| 123 | # Redo the actions |
| 124 | fileh.redo() |
| 125 | # Check that the copied node exists again in the object tree. |
| 126 | assert "/agroup/agroup2/anarray3" in fileh |
| 127 | assert "/agroup/anarray3" in fileh |
| 128 | assert "/agroup3/agroup2/anarray3" in fileh |
| 129 | assert "/agroup3/anarray3" not in fileh |
| 130 | assert fileh.root.agroup.anarray3 is new_node |
| 131 | assert "/anarray" not in fileh |
| 132 | assert "/anarray4" not in fileh |
| 133 | |
| 134 | # Tear down the file |
| 135 | tearDown(fileh) |
| 136 | |
| 137 | |
| 138 | if __name__ == "__main__": |
no test coverage detected