def lark_to_enum_value_node(tree: "Tree") -> "EnumValueNode": """ Creates and returns an EnumValueNode instance extracted from the parsing of the tree instance. :param tree: the Tree to parse in order to extract the proper node :type tree: Tree :return: an EnumValueNode instance extracted from the parsing of the tree :rtype: EnumValueNode """ return EnumValueNode(value=tree.children[0].value, location=lark_to_location_node(tree.meta))
def _parse_enum_value(enum_value_ast: dict) -> "EnumValueNode": """ Creates and returns an EnumValueNode instance from an enum value's JSON AST libgraphqlparser representation. :param enum_value_ast: enum value's JSON AST libgraphqlparser representation :type enum_value_ast: dict :return: an EnumValueNode instance equivalent to the JSON AST representation :rtype: EnumValueNode """ return EnumValueNode( value=enum_value_ast["value"], location=_parse_location(enum_value_ast["loc"]), )
def test_enumvaluenode__init__(): enum_value_node = EnumValueNode(value="enumValueValue", location="enumValueLocation") assert enum_value_node.value == "enumValueValue" assert enum_value_node.location == "enumValueLocation"
def test_booleanvaluenode__repr__(boolean_value_node, expected): assert boolean_value_node.__repr__() == expected def test_enumvaluenode__init__(): enum_value_node = EnumValueNode(value="enumValueValue", location="enumValueLocation") assert enum_value_node.value == "enumValueValue" assert enum_value_node.location == "enumValueLocation" @pytest.mark.parametrize( "enum_value_node,other,expected", [ ( EnumValueNode(value="enumValueValue", location="enumValueLocation"), Ellipsis, False, ), ( EnumValueNode(value="enumValueValue", location="enumValueLocation"), EnumValueNode(value="enumValueValueBis", location="enumValueLocation"), False, ), ( EnumValueNode(value="enumValueValue", location="enumValueLocation"), EnumValueNode(value="enumValueValue", location="enumValueLocationBis"),