"""Test node exercising the 'optional' flag on extended attributes"""
import omni.graph.core as og


class OgnTestOptionalExtended:
    @staticmethod
    def compute(db) -> bool:
        """Moves the 'other' input to the 'other' output if both of the optional attributes are not resolved,
        sets the 'other' output to the default value if only one of them is resolved, and copies the 'optional' input
        to the 'optional' output if both are resolved. (Since this is a test node we can count on the resolution types
        being compatible.)
        """
        if db.attributes.inputs.optional.get_resolved_type().base_type == og.BaseDataType.UNKNOWN:
            if db.attributes.outputs.optional.get_resolved_type().base_type == og.BaseDataType.UNKNOWN:
                db.outputs.other = db.inputs.other
            else:
                db.outputs.other = 10
        elif db.attributes.outputs.optional.get_resolved_type().base_type != og.BaseDataType.UNKNOWN:
            db.outputs.optional = db.inputs.optional
        else:
            db.outputs.other = 10
