CZ-NIC/yangson

RootNode.validate() fails when node represents an `action`

Closed this issue · 3 comments

In the xml-improved fork, there are two nearly identical tests:

  1. test_xml_rpc()
  2. test_xml_action()

test_xml_rpc() passes, but test_xml_action() with the message:

yangson.exceptions.SchemaError: [/] member-not-allowed: test:output

Why does the identical code work for an rpc but not an action? They are both instances of the same RpcActionNode class...

I should add that this issue is NOT XML-specific.

The relevant code is:

    output_obj = {
        "test:output" : {
            "leafL" : True
        }
    }

    # get the schema node for the 'action' 
    sn_action = data_model.get_schema_node("/test:contA/listA/contD/acA")
    assert(type(sn_action) == RpcActionNode)

    # convert raw object to an InstanceValue
    output_inst_val = sn_action.from_raw(output_obj, allow_nodata=True)
    assert(str(output_inst_val) == str(output_obj))

    # convert InstanceValue to an Instance (a RootNode)
    output_inst = RootNode(output_inst_val, sn_action, data_model.schema_data, output_inst_val.timestamp)
    #output_inst.validate(ctype=ContentType.all)  # fails, see Issue #88

Again, identical code validating an RPC's output works fine.

Fixed in version 1.3.65.