def set_value(self, node_id, value_type_identifier, desired_value):
        """Set value on the OPC UA server. example parameters:
            Node_id=ns=4;s=node_name,
            value_type_identifier 0-25

            see: https://github.com/FreeOpcUa/python-opcua/blob/master/opcua/ua/uatypes.py#L619),
            desired_value could be any value that matches the UA Type
        """
        parsed_value, opc_type = map_to_opcua_type_and_value(
            value_type_identifier, desired_value)
        self.ensure_connection()
        node = self._client.get_node(node_id)
        dv = ua.DataValue(ua.Variant(parsed_value, opc_type))
        node.set_value(dv)
def test_when_passed_in_identifier_as_14_should_parse_to_guid():
    value, opc_type = utility.map_to_opcua_type_and_value(14, '3ca5c721-cb26-4be5-92a5-ac6f413113be')
    assert type(value) is uid.UUID
    assert opc_type == ua.VariantType.Guid

# TODO: we should add more tests for routes
def test_when_passed_in_identifier_as_13_should_parse_to_datetime():
    value, opc_type = utility.map_to_opcua_type_and_value(13, '2018-08-15 10:10:00')
    print(str(value))
    assert type(value) is datetime
    assert opc_type == ua.VariantType.DateTime
def test_when_passed_in_identifier_as_0_should_parse_to_null():
    value, opc_type = utility.map_to_opcua_type_and_value(0, '')
    assert value is None
    assert opc_type == ua.VariantType.Null
def test_when_passed_in_identifier_as_12_should_parse_to_string():
    value, opc_type = utility.map_to_opcua_type_and_value(12, 'I am a string')
    assert type(value) is str
    assert opc_type == ua.VariantType.String
def test_when_passed_in_identifier_as_11_should_parse_to_double():
    value, opc_type = utility.map_to_opcua_type_and_value(11, '100.11')
    assert type(value) is float
    assert opc_type == ua.VariantType.Double
def test_when_passed_in_identifier_as_10_should_parse_to_float():
    value, opc_type = utility.map_to_opcua_type_and_value(10, '100.0')
    assert type(value) is float
    assert opc_type == ua.VariantType.Float
def test_when_passed_in_identifier_as_9_should_parse_to_uint64():
    value, opc_type = utility.map_to_opcua_type_and_value(9, '99')
    assert type(value) is int
    assert opc_type == ua.VariantType.UInt64
def test_when_passed_in_identifier_as_6_should_parse_to_int32():
    value, opc_type = utility.map_to_opcua_type_and_value(6, '66')
    assert type(value) is int
    assert opc_type == ua.VariantType.Int32
def test_when_passed_in_identifier_as_3_should_parse_to_byte():
    value, opc_type = utility.map_to_opcua_type_and_value(3, '1')
    assert type(value) is int
    assert value is 1
    assert opc_type == ua.VariantType.Byte
def test_when_passed_in_identifier_as_1_should_parse_to_boolean():
    value, opc_type = utility.map_to_opcua_type_and_value(1, 'true')
    assert type(value) is bool
    assert value is True
    assert opc_type == ua.VariantType.Boolean