Skip to content

Commit

Permalink
add test for delete
Browse files Browse the repository at this point in the history
  • Loading branch information
oroulet committed Feb 8, 2019
1 parent 845c152 commit fbe12ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
23 changes: 12 additions & 11 deletions test_uamodeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
from uawidgets.new_node_dialogs import NewNodeBaseDialog, NewUaObjectDialog, NewUaVariableDialog, NewUaMethodDialog


# README: QApplication.exec() is never called so if you call somehting dependingon some earlier events,
# call app.processEvents() jsut before
global app


@pytest.fixture(scope="module")
def modeler():
global app
app = QApplication(sys.argv)
modeler = UaModeler()
yield modeler
Expand Down Expand Up @@ -80,32 +86,27 @@ def test_save_open_ua_model(modeler, mgr):
mgr.close_model()


@pytest.mark.skip("Something wrong with expand_to_node")
def test_delete_save(modeler, mgr):
#@pytest.mark.skip("Something wrong with expand_to_node")
def test_delete_save(modeler, mgr, model):
path = "test_delete_save.uamodel"
val = 0.99
mgr.new_model()
modeler.tree_ui.expand_to_node("Objects")
obj_node = mgr.add_folder(1, "myobj")
modeler.tree_ui.expand_to_node("Objects")
modeler.tree_ui.expand_to_node("myobj")
obj2_node = mgr.add_folder(1, "myobj2")
modeler.tree_ui.reload_current()

app.processEvents()
modeler.tree_ui.expand_to_node("myobj2")
#var_node = mgr.add_variable(1, "myvar", val)
var_node = mgr.add_variable(1, "myvar", val)
mgr.save_ua_model(path)
mgr.save_xml(path)

modeler.tree_ui.expand_to_node("myobj2")
app.processEvents()
modeler.tree_ui.expand_to_node(obj2_node)
mgr.delete_node(obj2_node)
mgr.save_ua_model(path)
mgr.save_xml(path)
assert obj2_node not in mgr.new_nodes
assert var_node not in mgr.new_nodes

mgr.close_model(force=True)


def test_structs(modeler, mgr):
mgr.new_model()
Expand Down
3 changes: 0 additions & 3 deletions uamodeler/model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,12 @@ def _get_datatype_from_string(self, idx, name):
return None

def open(self, path):
print("OPEN", path)
if path.endswith(".xml"):
self.open_xml(path)
else:
self.open_ua_model(path)

def open_ua_model(self, path):
print("OPEN UA", path)
self.new_model()
try:
self._open_ua_model(path)
Expand All @@ -190,7 +188,6 @@ def open_ua_model(self, path):
raise

def _open_ua_model(self, path):
print("OPEN UA", path)
tree = Et.parse(path)
root = tree.getroot()
for ref_el in root.findall("Reference"):
Expand Down

0 comments on commit fbe12ff

Please sign in to comment.