Пример #1
0
def lark_to_null_value_node(tree: "Tree") -> "NullValueNode":
    """
    Creates and returns a NullValueNode 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 NullValueNode instance extracted from the parsing of the tree
    :rtype: NullValueNode
    """
    return NullValueNode(location=lark_to_location_node(tree.meta))
Пример #2
0
def _parse_null_value(null_value_ast: dict) -> "NullValueNode":
    """
    Creates and returns a NullValueNode instance from a null value's JSON AST
    libgraphqlparser representation.
    :param null_value_ast: null value's JSON AST libgraphqlparser
    representation
    :type null_value_ast: dict
    :return: a NullValueNode instance equivalent to the JSON AST representation
    :rtype: NullValueNode
    """
    return NullValueNode(location=_parse_location(null_value_ast["loc"]))
Пример #3
0
def test_nullvaluenode__init__():
    null_value_node = NullValueNode(location="nullValueLocation")
    assert null_value_node.value is None
    assert null_value_node.location == "nullValueLocation"
Пример #4
0
    )],
)
def test_intvaluenode__repr__(int_value_node, expected):
    assert int_value_node.__repr__() == expected


def test_nullvaluenode__init__():
    null_value_node = NullValueNode(location="nullValueLocation")
    assert null_value_node.value is None
    assert null_value_node.location == "nullValueLocation"


@pytest.mark.parametrize(
    "null_value_node,other,expected",
    [
        (NullValueNode(location="nullValueLocation"), Ellipsis, False),
        (
            NullValueNode(location="nullValueLocation"),
            NullValueNode(location="nullValueLocationBis"),
            False,
        ),
        (
            NullValueNode(location="nullValueLocation"),
            NullValueNode(location="nullValueLocation"),
            True,
        ),
    ],
)
def test_nullvaluenode__eq__(null_value_node, other, expected):
    assert (null_value_node == other) is expected