def lark_to_list_value_node(tree: "Tree") -> "ListValueNode": """ Creates and returns a ListValueNode 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: a ListValueNode instance extracted from the parsing of the tree :rtype: ListValueNode """ return ListValueNode( values=[child.value for child in tree.children], location=lark_to_location_node(tree.meta), )
def _parse_list_value(list_value_ast: dict) -> "ListValueNode": """ Creates and returns a ListValueNode instance from a list value's JSON AST libgraphqlparser representation. :param list_value_ast: list value's JSON AST libgraphqlparser representation :type list_value_ast: dict :return: a ListValueNode instance equivalent to the JSON AST representation :rtype: ListValueNode """ return ListValueNode( values=_parse_values(list_value_ast["values"]), location=_parse_location(list_value_ast["loc"]), )
def _parse_list_value(list_value_ast: dict, validators: Validators, path: Path) -> "ListValueNode": """ Creates and returns a ListValueNode instance from a list value's JSON AST libgraphqlparser representation. :param list_value_ast: list value's JSON AST libgraphqlparser representation :type list_value_ast: dict :param validators: the validators to use in order to validate this definition :type validators: Validators :param path: a Path object that contains the current field path :type path: Path :return: a ListValueNode instance equivalent to the JSON AST representation :rtype: ListValueNode """ return ListValueNode( values=_parse_values(list_value_ast["values"], validators, path), location=_parse_location(list_value_ast["loc"]), )
def test_listvaluenode__init__(): list_value_node = ListValueNode(values="listValueValues", location="listValueLocation") assert list_value_node.values == "listValueValues" assert list_value_node.location == "listValueLocation"
def test_stringvaluenode__repr__(string_value_node, expected): assert string_value_node.__repr__() == expected def test_listvaluenode__init__(): list_value_node = ListValueNode(values="listValueValues", location="listValueLocation") assert list_value_node.values == "listValueValues" assert list_value_node.location == "listValueLocation" @pytest.mark.parametrize( "list_value_node,other,expected", [ ( ListValueNode(values="listValueValues", location="listValueLocation"), Ellipsis, False, ), ( ListValueNode(values="listValueValues", location="listValueLocation"), ListValueNode(values="listValueValuesBis", location="listValueLocation"), False, ), ( ListValueNode(values="listValueValues", location="listValueLocation"), ListValueNode(values="listValueValues", location="listValueLocationBis"),