示例#1
0
def test_add_variable_float_fail(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler, "Add Variable", modeler.get_current_server(), dtype=ua.ObjectIds.Float)
    dia.valLineEdit.setText("oiuiu")
    with pytest.raises(ValueError):
        args = dia.get_args()
        new_node = mgr.add_variable(*args)
示例#2
0
def test_add_variable_double_list(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler, "Add Variable", modeler.get_current_server(), dtype=ua.ObjectIds.Double)
    args = dia.get_args()
    new_node = mgr.add_variable(*args)
    assert new_node in modeler.get_current_server().nodes.objects.get_children()
    assert isinstance(new_node.get_value(), float)
示例#3
0
 def test_add_variable_double_list(self):
     self.modeler.tree_ui.expand_to_node("Objects")
     val = [9.9, 5.5, 1.2]
     dia = NewUaVariableDialog(self.modeler, "Add Variable", self.modeler.get_current_server(), default_value=val, dtype=ua.ObjectIds.Double)
     args = dia.get_args()
     new_node = self.mgr.add_variable(*args)
     self.assertIn(new_node, self.modeler.get_current_server().nodes.objects.get_children())
     self.assertEqual(val, new_node.get_value())
示例#4
0
def test_add_variable_bytes(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler, "Add Variable", modeler.get_current_server(), dtype=ua.ObjectIds.ByteString)
    val = b"lkjkjl"
    dia.valLineEdit.setText(val.decode())
    args = dia.get_args()
    new_node = mgr.add_variable(*args)
    assert new_node in modeler.get_current_server().nodes.objects.get_children()
    assert val == new_node.get_value()
示例#5
0
 def test_add_variable_float_fail(self):
     self.modeler.tree_ui.expand_to_node("Objects")
     dia = NewUaVariableDialog(self.modeler,
                               "Add Variable",
                               self.modeler.get_current_server(),
                               default_value=b"lkjkl",
                               dtype=ua.ObjectIds.Float)
     with self.assertRaises(ValueError):
         args = dia.get_args()
         new_node = self.mgr.add_variable(*args)
示例#6
0
def test_add_variable_float_fail(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler,
                              "Add Variable",
                              modeler.get_current_server(),
                              dtype=ua.ObjectIds.Float)
    dia.valLineEdit.setText("oiuiu")
    with pytest.raises(ValueError):
        args = dia.get_args()
        new_node = mgr.add_variable(*args)
示例#7
0
def test_add_variable_extobj(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler,
                              "Add Variable",
                              modeler.get_current_server(),
                              dtype=ua.ObjectIds.Structure)
    args = dia.get_args()
    new_node = mgr.add_variable(*args)
    assert new_node in modeler.get_current_server().nodes.objects.get_children(
    )
示例#8
0
def test_add_variable_double_list(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler,
                              "Add Variable",
                              modeler.get_current_server(),
                              dtype=ua.ObjectIds.Double)
    args = dia.get_args()
    new_node = mgr.add_variable(*args)
    assert new_node in modeler.get_current_server().nodes.objects.get_children(
    )
    assert isinstance(new_node.read_value(), float)
示例#9
0
 def test_add_variable_bytes(self):
     self.modeler.tree_ui.expand_to_node("Objects")
     dia = NewUaVariableDialog(self.modeler,
                               "Add Variable",
                               self.modeler.get_current_server(),
                               default_value=b"lkjkl",
                               dtype=ua.ObjectIds.ByteString)
     args = dia.get_args()
     new_node = self.mgr.add_variable(*args)
     self.assertIn(
         new_node,
         self.modeler.get_current_server().nodes.objects.get_children())
示例#10
0
 def test_add_variable_double(self):
     self.modeler.tree_ui.set_current_node("Objects")
     dia = NewUaVariableDialog(self.modeler,
                               "Add Variable",
                               self.modeler.get_current_server(),
                               default_value=9.99,
                               dtype=ua.ObjectIds.Double)
     args = dia.get_args()
     new_node = self.modeler.model_mgr.add_variable(*args)
     self.assertIn(
         new_node,
         self.modeler.get_current_server().nodes.objects.get_children())
示例#11
0
def test_add_variable_bytes(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler,
                              "Add Variable",
                              modeler.get_current_server(),
                              dtype=ua.ObjectIds.ByteString)
    val = b"lkjkjl"
    dia.valLineEdit.setText(val.decode())
    args = dia.get_args()
    new_node = mgr.add_variable(*args)
    assert new_node in modeler.get_current_server().nodes.objects.get_children(
    )
    assert val == new_node.read_value()
示例#12
0
def test_add_variable_extobj(modeler, mgr, model):
    modeler.tree_ui.expand_to_node("Objects")
    dia = NewUaVariableDialog(modeler, "Add Variable", modeler.get_current_server(), dtype=ua.ObjectIds.Structure)
    args = dia.get_args()
    new_node = mgr.add_variable(*args)
    assert new_node in modeler.get_current_server().nodes.objects.get_children()