Пример #1
0
 def match(self, root_value: object,
           current_value: object) -> Generator[MatchData, None, None]:
     """Match the current value against the root value."""
     if isinstance(current_value, Mapping) and (self.index
                                                in current_value):
         return [
             MatchData(
                 SubscriptNode(TerminalNode(), [self]),
                 root_value,
                 current_value[self.index],
             )
         ]
     return []
Пример #2
0
 def exitSubscript(self, ctx: JSONPathParser.SubscriptContext):
     if ctx.getToken(JSONPathParser.RECURSIVE_DESCENT, 0) is not None:
         if bool(ctx.subscript()):
             next_node = self._stack.pop()
         else:
             next_node = TerminalNode()
         if bool(ctx.subscriptableBareword()):
             subscriptable_nodes = [self._stack.pop()]
         elif bool(ctx.subscriptables()):
             subscriptable_nodes = self._stack.pop()
         else:
             # NOTE Unreachable when listener is used as tree walker.
             raise ValueError()  # pragma: no cover
         self._stack.append(
             RecursiveDescentNode(
                 SubscriptNode(next_node, subscriptable_nodes)))
     elif ctx.getToken(JSONPathParser.SUBSCRIPT, 0) is not None:
         if bool(ctx.subscript()):
             next_node = self._stack.pop()
         else:
             next_node = TerminalNode()
         if bool(ctx.subscriptableBareword()):
             subscriptable_nodes = [self._stack.pop()]
         else:
             # NOTE Unreachable when listener is used as tree walker.
             raise ValueError()  # pragma: no cover
         self._stack.append(SubscriptNode(next_node, subscriptable_nodes))
     else:
         if bool(ctx.subscript()):
             next_node = self._stack.pop()
         else:
             next_node = TerminalNode()
         if bool(ctx.subscriptables()):
             subscriptable_nodes = self._stack.pop()
         else:
             # NOTE Unreachable when listener is used as tree walker.
             raise ValueError()  # pragma: no cover
         self._stack.append(SubscriptNode(next_node, subscriptable_nodes))
Пример #3
0
    def test_badsubscript2(self):
        """Test subscript that provides other subscript but not subscripted-terminal."""
        class BadSubscript2(Subscript):
            """Subscript that provides other subscript but not subscripted-terminal."""
            def __jsonpath__(self):
                """Empty."""
                return []

            def match(self, root_value, current_value):
                """One."""
                yield MatchData(SubscriptNode(None), root_value, current_value)

        self.assertEqual('', BadSubscript2().tojsonpath())

        with self.assertRaises(ValueError):
            # NOTE Use 'list' to force the computation to occur, raising any exceptions.
            list(
                SubscriptNode(TerminalNode(),
                              [BadSubscript2()]).match(None, None))
Пример #4
0
 def match(self, root_value, current_value):
     """One."""
     yield MatchData(SubscriptNode(None), root_value, current_value)
    def setUp(self):
        """Setup the class."""
        root_value = {
            'hello': 'Hello, world!',
            'languages': [
                'en-GB',
                'en-US',
            ],
        }
        current_value = root_value['hello']

        self._state = [
            {
                '__jsonpath__':
                '',
                'node':
                TerminalNode(),
                'root_value':
                root_value,
                'current_value':
                current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__':
                '$',
                'node':
                RootNode(TerminalNode()),
                'root_value':
                root_value,
                'current_value':
                current_value,
                'match_data_list': [
                    MatchData(RootNode(TerminalNode()), root_value,
                              root_value),
                ],
            },
            {
                '__jsonpath__':
                '@',
                'node':
                CurrentNode(TerminalNode()),
                'root_value':
                root_value,
                'current_value':
                current_value,
                'match_data_list': [
                    MatchData(CurrentNode(TerminalNode()), root_value,
                              current_value),
                ],
            },
            {
                '__jsonpath__': '[]',
                'node': SubscriptNode(TerminalNode(), []),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [],
            },
            {
                '__jsonpath__':
                '[?(@)]',
                'node':
                SubscriptNode(TerminalNode(), [
                    FilterSubscript(SomeExpression(CurrentNode(
                        TerminalNode())))
                ]),
                'root_value':
                root_value,
                'current_value':
                current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__':
                '[?(@),?(@)]',
                'node':
                SubscriptNode(TerminalNode(), [
                    FilterSubscript(SomeExpression(CurrentNode(
                        TerminalNode()))),
                    FilterSubscript(SomeExpression(CurrentNode(
                        TerminalNode())))
                ]),
                'root_value':
                root_value,
                'current_value':
                current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__': '[*]',
                'node': SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [],
            },
            {
                '__jsonpath__':
                '[*]',
                'node':
                SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('hello')]),
                        root_value, root_value['hello']),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('languages')]),
                        root_value, root_value['languages']),
                ],
            },
            {
                '__jsonpath__':
                '["languages"][*]',
                'node':
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                    [ObjectIndexSubscript('languages')]),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][0]),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][1]),
                ],
            },
            {
                '__jsonpath__':
                '["hello","languages"]',
                'node':
                SubscriptNode(TerminalNode(), [
                    ObjectIndexSubscript('hello'),
                    ObjectIndexSubscript('languages')
                ]),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('hello')]),
                        root_value, root_value['hello']),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('languages')]),
                        root_value, root_value['languages']),
                ],
            },
            {
                '__jsonpath__':
                '..',
                'node':
                RecursiveDescentNode(TerminalNode()),
                'root_value':
                root_value,
                'current_value':
                current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__':
                '..',
                'node':
                RecursiveDescentNode(TerminalNode()),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, root_value),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('hello')]),
                        root_value, root_value['hello']),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('languages')]),
                        root_value, root_value['languages']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][0]),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][1]),
                ],
            },
            {
                '__jsonpath__':
                '..[?(@)]',
                'node':
                RecursiveDescentNode(
                    SubscriptNode(TerminalNode(), [
                        FilterSubscript(
                            SomeExpression(CurrentNode(TerminalNode())))
                    ])),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, root_value),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('hello')]),
                        root_value, root_value['hello']),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('languages')]),
                        root_value, root_value['languages']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][0]),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][1]),
                ],
            },
            {
                '__jsonpath__':
                '..[*]',
                'node':
                RecursiveDescentNode(
                    SubscriptNode(TerminalNode(), [WildcardSubscript()])),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('hello')]),
                        root_value, root_value['hello']),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('languages')]),
                        root_value, root_value['languages']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][0]),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][1]),
                ],
            },
            {
                '__jsonpath__':
                '..["hello"]',
                'node':
                RecursiveDescentNode(
                    SubscriptNode(TerminalNode(),
                                  [ObjectIndexSubscript('hello')])),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript('hello')]),
                        root_value, root_value['hello']),
                ],
            },
            {
                '__jsonpath__':
                '..[0]',
                'node':
                RecursiveDescentNode(
                    SubscriptNode(TerminalNode(), [ArrayIndexSubscript(0)])),
                'root_value':
                root_value,
                'current_value':
                root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript('languages')]), root_value,
                        root_value['languages'][0]),
                ],
            },
        ]
Пример #6
0
    def setUp(self):
        """Setup the class."""
        root_value = {
            'hello': 'Hello, world!',
            'languages': [
                'en-GB',
                'en-US',
            ],
            'preferences': {
                'coffee': True,
                'tea': False,
            },
        }
        current_value = root_value['hello']

        self._state = [
            {
                '__jsonpath__': '',
                'node': TerminalNode(),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__': '$',
                'node': RootNode(TerminalNode()),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [
                    MatchData(RootNode(TerminalNode()),
                              root_value, root_value),
                ],
            },
            {
                '__jsonpath__': '@',
                'node': CurrentNode(TerminalNode()),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [
                    MatchData(CurrentNode(TerminalNode()),
                              root_value, current_value),
                ],
            },
            {
                '__jsonpath__': '[]',
                'node': SubscriptNode(TerminalNode(), []),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [],
            },
            {
                '__jsonpath__': '[?(@)]',
                'node': SubscriptNode(TerminalNode(), [FilterSubscript(SomeExpression(CurrentNode(TerminalNode())))]),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__': '[?(@),?(@)]',
                'node': SubscriptNode(
                    TerminalNode(),
                    [
                        FilterSubscript(SomeExpression(
                            CurrentNode(TerminalNode()))),
                        FilterSubscript(SomeExpression(
                            CurrentNode(TerminalNode())))
                    ]
                ),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__': '[*]',
                'node': SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [],
            },
            {
                '__jsonpath__': '[*]',
                'node': SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'hello')]), root_value, root_value['hello']),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'languages')]), root_value, root_value['languages']),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'preferences')]), root_value, root_value['preferences']),
                ],
            },
            {
                '__jsonpath__': '["languages"][*]',
                'node': SubscriptNode(
                    SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                    [ObjectIndexSubscript('languages')]
                ),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(0)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][0]
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][1]
                    ),
                ],
            },
            {
                '__jsonpath__': '["hello","languages"]',
                'node': SubscriptNode(
                    TerminalNode(),
                    [ObjectIndexSubscript('hello'),
                     ObjectIndexSubscript('languages')]
                ),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'hello')]), root_value, root_value['hello']),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'languages')]), root_value, root_value['languages']),
                ],
            },
            {
                '__jsonpath__': '..',
                'node': RecursiveDescentNode(TerminalNode()),
                'root_value': root_value,
                'current_value': current_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                '__jsonpath__': '..',
                'node': RecursiveDescentNode(TerminalNode()),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, root_value),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'hello')]), root_value, root_value['hello']),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'languages')]), root_value, root_value['languages']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(0)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][0]
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(1)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][1]
                    ),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'preferences')]), root_value, root_value['preferences']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ObjectIndexSubscript('coffee')]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        root_value['preferences']['coffee']
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ObjectIndexSubscript('tea')]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        root_value['preferences']['tea']
                    ),
                ],
            },
            {
                '__jsonpath__': '..[?(@)]',
                'node': RecursiveDescentNode(
                    SubscriptNode(
                        TerminalNode(),
                        [
                            FilterSubscript(SomeExpression(
                                CurrentNode(TerminalNode())))
                        ]
                    )
                ),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(TerminalNode(), root_value, root_value),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'hello')]), root_value, root_value['hello']),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'languages')]), root_value, root_value['languages']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(0)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][0]
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(1)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][1]
                    ),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'preferences')]), root_value, root_value['preferences']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ObjectIndexSubscript('coffee')]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        root_value['preferences']['coffee']
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ObjectIndexSubscript('tea')]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        root_value['preferences']['tea']
                    ),
                ],
            },
            {
                '__jsonpath__': '..[*]',
                'node': RecursiveDescentNode(SubscriptNode(TerminalNode(), [WildcardSubscript()])),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'hello')]), root_value, root_value['hello']),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'languages')]), root_value, root_value['languages']),
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'preferences')]), root_value, root_value['preferences']),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(0)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][0]
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(1)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][1]
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ObjectIndexSubscript('coffee')]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        root_value['preferences']['coffee']
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ObjectIndexSubscript('tea')]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        root_value['preferences']['tea']
                    ),
                ],
            },
            {
                '__jsonpath__': '..["hello"]',
                'node': RecursiveDescentNode(SubscriptNode(TerminalNode(), [ObjectIndexSubscript('hello')])),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(SubscriptNode(TerminalNode(), [ObjectIndexSubscript(
                        'hello')]), root_value, root_value['hello']),
                ],
            },
            {
                '__jsonpath__': '..[0]',
                'node': RecursiveDescentNode(SubscriptNode(TerminalNode(), [ArrayIndexSubscript(0)])),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ArrayIndexSubscript(0)]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages'][0]
                    ),
                ],
            },
            {
                '__jsonpath__': '["hello"][length()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [LengthCallableSubscript()]), [ObjectIndexSubscript('hello')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [LengthCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('hello')]
                        ),
                        root_value,
                        len(root_value['hello'])
                    ),
                ],
            },
            {
                '__jsonpath__': '["hello"][charAt(0)]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [CharAtCallableSubscript(0)]), [ObjectIndexSubscript('hello')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [CharAtCallableSubscript(MatchData(TerminalNode(), root_value, 0))]
                            ),
                            [ObjectIndexSubscript('hello')]
                        ),
                        root_value,
                        root_value['hello'][0]
                    ),
                ],
            },
            {
                '__jsonpath__': '["hello"][charAt(1000)]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [CharAtCallableSubscript(1000)]), [ObjectIndexSubscript('hello')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [],
            },
            {
                '__jsonpath__': '["hello"][charAt($["hello"][length()])]',
                'node': SubscriptNode(SubscriptNode(TerminalNode(), [CharAtCallableSubscript(
                    RootNode(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [LengthCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('hello')]
                        )
                    )
                )]), [ObjectIndexSubscript('hello')]),
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [],
            },
            {
                '__jsonpath__': '["hello"][substring(1)]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [SubstringCallableSubscript(1)]), [ObjectIndexSubscript('hello')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [SubstringCallableSubscript(MatchData(TerminalNode(), root_value, 1))]
                            ),
                            [ObjectIndexSubscript('hello')]
                        ),
                        root_value,
                        root_value['hello'][1:]
                    ),
                ],
            },
            {
                '__jsonpath__': '["hello"][substring(1,3)]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [SubstringCallableSubscript(1, 3)]), [ObjectIndexSubscript('hello')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [SubstringCallableSubscript(MatchData(TerminalNode(), root_value, 1),
                                                            MatchData(TerminalNode(), root_value, 3))]
                            ),
                            [ObjectIndexSubscript('hello')]
                        ),
                        root_value,
                        root_value['hello'][1:3]
                    ),
                ],
            },
            {
                '__jsonpath__': '["languages"][length()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [LengthCallableSubscript()]), [ObjectIndexSubscript('languages')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [LengthCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        len(root_value['languages'])
                    ),
                ],
            },
            {
                '__jsonpath__': '["languages"][entries()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [EntriesCallableSubscript()]), [ObjectIndexSubscript('languages')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [EntriesCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        list(map(list, enumerate(root_value['languages'])))
                    ),
                ],
            },
            {
                '__jsonpath__': '["languages"][keys()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [KeysCallableSubscript()]), [ObjectIndexSubscript('languages')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [KeysCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        list(range(len(root_value['languages'])))
                    ),
                ],
            },
            {
                '__jsonpath__': '["languages"][values()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [ValuesCallableSubscript()]), [ObjectIndexSubscript('languages')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ValuesCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('languages')]
                        ),
                        root_value,
                        root_value['languages']
                    ),
                ],
            },
            {
                '__jsonpath__': '["preferences"][entries()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [EntriesCallableSubscript()]), [ObjectIndexSubscript('preferences')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [EntriesCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        list(map(list, root_value['preferences'].items()))
                    ),
                ],
            },
            {
                '__jsonpath__': '["preferences"][keys()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [KeysCallableSubscript()]), [ObjectIndexSubscript('preferences')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [KeysCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        list(root_value['preferences'].keys())
                    ),
                ],
            },
            {
                '__jsonpath__': '["preferences"][values()]',
                # pylint: disable=line-too-long
                'node': SubscriptNode(SubscriptNode(TerminalNode(),
                                                    [ValuesCallableSubscript()]), [ObjectIndexSubscript('preferences')]),  # noqa: E501
                # pylint: enable=line-too-long
                'root_value': root_value,
                'current_value': root_value,
                'match_data_list': [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [ValuesCallableSubscript()]
                            ),
                            [ObjectIndexSubscript('preferences')]
                        ),
                        root_value,
                        list(root_value['preferences'].values())
                    ),
                ],
            },
        ]
Пример #7
0
    def setUp(self):
        """Setup the class."""
        root_value = {
            "hello": "Hello, world!",
            "languages": [
                "en-GB",
                "en-US",
            ],
            "preferences": {
                "coffee": True,
                "tea": False,
            },
        }
        current_value = root_value["hello"]

        self._state = [
            {
                "__jsonpath__":
                "",
                "node":
                TerminalNode(),
                "root_value":
                root_value,
                "current_value":
                current_value,
                "match_data_list": [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                "__jsonpath__":
                "$",
                "node":
                RootNode(TerminalNode()),
                "root_value":
                root_value,
                "current_value":
                current_value,
                "match_data_list": [
                    MatchData(RootNode(TerminalNode()), root_value,
                              root_value),
                ],
            },
            {
                "__jsonpath__":
                "@",
                "node":
                CurrentNode(TerminalNode()),
                "root_value":
                root_value,
                "current_value":
                current_value,
                "match_data_list": [
                    MatchData(CurrentNode(TerminalNode()), root_value,
                              current_value),
                ],
            },
            {
                "__jsonpath__": "[]",
                "node": SubscriptNode(TerminalNode(), []),
                "root_value": root_value,
                "current_value": current_value,
                "match_data_list": [],
            },
            {
                "__jsonpath__":
                "[?(@)]",
                "node":
                SubscriptNode(
                    TerminalNode(),
                    [
                        FilterSubscript(
                            SomeExpression(CurrentNode(TerminalNode())))
                    ],
                ),
                "root_value":
                root_value,
                "current_value":
                current_value,
                "match_data_list": [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                "__jsonpath__":
                "[?(@),?(@)]",
                "node":
                SubscriptNode(
                    TerminalNode(),
                    [
                        FilterSubscript(
                            SomeExpression(CurrentNode(TerminalNode()))),
                        FilterSubscript(
                            SomeExpression(CurrentNode(TerminalNode()))),
                    ],
                ),
                "root_value":
                root_value,
                "current_value":
                current_value,
                "match_data_list": [
                    MatchData(TerminalNode(), root_value, current_value),
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                "__jsonpath__": "[*]",
                "node": SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                "root_value": root_value,
                "current_value": current_value,
                "match_data_list": [],
            },
            {
                "__jsonpath__":
                "[*]",
                "node":
                SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("hello")]),
                        root_value,
                        root_value["hello"],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("languages")]),
                        root_value,
                        root_value["languages"],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("preferences")]),
                        root_value,
                        root_value["preferences"],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["languages"][*]',
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [WildcardSubscript()]),
                    [ObjectIndexSubscript("languages")],
                ),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][0],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][1],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["hello","languages"]',
                "node":
                SubscriptNode(
                    TerminalNode(),
                    [
                        ObjectIndexSubscript("hello"),
                        ObjectIndexSubscript("languages")
                    ],
                ),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("hello")]),
                        root_value,
                        root_value["hello"],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("languages")]),
                        root_value,
                        root_value["languages"],
                    ),
                ],
            },
            {
                "__jsonpath__":
                "..",
                "node":
                RecursiveDescentNode(TerminalNode()),
                "root_value":
                root_value,
                "current_value":
                current_value,
                "match_data_list": [
                    MatchData(TerminalNode(), root_value, current_value),
                ],
            },
            {
                "__jsonpath__":
                "..",
                "node":
                RecursiveDescentNode(TerminalNode()),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(TerminalNode(), root_value, root_value),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("hello")]),
                        root_value,
                        root_value["hello"],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("languages")]),
                        root_value,
                        root_value["languages"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][0],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][1],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("preferences")]),
                        root_value,
                        root_value["preferences"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ObjectIndexSubscript("coffee")]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        root_value["preferences"]["coffee"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ObjectIndexSubscript("tea")]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        root_value["preferences"]["tea"],
                    ),
                ],
            },
            {
                "__jsonpath__":
                "..[?(@)]",
                "node":
                RecursiveDescentNode(
                    SubscriptNode(
                        TerminalNode(),
                        [
                            FilterSubscript(
                                SomeExpression(CurrentNode(TerminalNode())))
                        ],
                    )),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(TerminalNode(), root_value, root_value),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("hello")]),
                        root_value,
                        root_value["hello"],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("languages")]),
                        root_value,
                        root_value["languages"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][0],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][1],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("preferences")]),
                        root_value,
                        root_value["preferences"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ObjectIndexSubscript("coffee")]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        root_value["preferences"]["coffee"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ObjectIndexSubscript("tea")]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        root_value["preferences"]["tea"],
                    ),
                ],
            },
            {
                "__jsonpath__":
                "..[*]",
                "node":
                RecursiveDescentNode(
                    SubscriptNode(TerminalNode(), [WildcardSubscript()])),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("hello")]),
                        root_value,
                        root_value["hello"],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("languages")]),
                        root_value,
                        root_value["languages"],
                    ),
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("preferences")]),
                        root_value,
                        root_value["preferences"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][0],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(1)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][1],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ObjectIndexSubscript("coffee")]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        root_value["preferences"]["coffee"],
                    ),
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ObjectIndexSubscript("tea")]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        root_value["preferences"]["tea"],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '..["hello"]',
                "node":
                RecursiveDescentNode(
                    SubscriptNode(TerminalNode(),
                                  [ObjectIndexSubscript("hello")])),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(TerminalNode(),
                                      [ObjectIndexSubscript("hello")]),
                        root_value,
                        root_value["hello"],
                    ),
                ],
            },
            {
                "__jsonpath__":
                "..[0]",
                "node":
                RecursiveDescentNode(
                    SubscriptNode(TerminalNode(), [ArrayIndexSubscript(0)])),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ArrayIndexSubscript(0)]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"][0],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["hello"][length()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [LengthCallableSubscript()]),
                    [ObjectIndexSubscript("hello")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [LengthCallableSubscript()]),
                            [ObjectIndexSubscript("hello")],
                        ),
                        root_value,
                        len(root_value["hello"]),
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["hello"][charAt(0)]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(),
                                  [CharAtCallableSubscript(0)]),
                    [ObjectIndexSubscript("hello")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [
                                    CharAtCallableSubscript(
                                        MatchData(TerminalNode(), root_value,
                                                  0))
                                ],
                            ),
                            [ObjectIndexSubscript("hello")],
                        ),
                        root_value,
                        root_value["hello"][0],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["hello"][charAt(1000)]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(),
                                  [CharAtCallableSubscript(1000)]),
                    [ObjectIndexSubscript("hello")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [],
            },
            {
                "__jsonpath__":
                '["hello"][charAt($["hello"][length()])]',
                "node":
                SubscriptNode(
                    SubscriptNode(
                        TerminalNode(),
                        [
                            CharAtCallableSubscript(
                                RootNode(
                                    SubscriptNode(
                                        SubscriptNode(
                                            TerminalNode(),
                                            [LengthCallableSubscript()]),
                                        [ObjectIndexSubscript("hello")],
                                    )))
                        ],
                    ),
                    [ObjectIndexSubscript("hello")],
                ),
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [],
            },
            {
                "__jsonpath__":
                '["hello"][substring(1)]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(),
                                  [SubstringCallableSubscript(1)]),
                    [ObjectIndexSubscript("hello")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [
                                    SubstringCallableSubscript(
                                        MatchData(TerminalNode(), root_value,
                                                  1))
                                ],
                            ),
                            [ObjectIndexSubscript("hello")],
                        ),
                        root_value,
                        root_value["hello"][1:],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["hello"][substring(1,3)]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(),
                                  [SubstringCallableSubscript(1, 3)]),
                    [ObjectIndexSubscript("hello")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(
                                TerminalNode(),
                                [
                                    SubstringCallableSubscript(
                                        MatchData(TerminalNode(), root_value,
                                                  1),
                                        MatchData(TerminalNode(), root_value,
                                                  3),
                                    )
                                ],
                            ),
                            [ObjectIndexSubscript("hello")],
                        ),
                        root_value,
                        root_value["hello"][1:3],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["languages"][length()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [LengthCallableSubscript()]),
                    [ObjectIndexSubscript("languages")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [LengthCallableSubscript()]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        len(root_value["languages"]),
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["languages"][entries()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(),
                                  [EntriesCallableSubscript()]),
                    [ObjectIndexSubscript("languages")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [EntriesCallableSubscript()]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        list(map(list, enumerate(root_value["languages"]))),
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["languages"][keys()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [KeysCallableSubscript()]),
                    [ObjectIndexSubscript("languages")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [KeysCallableSubscript()]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        list(range(len(root_value["languages"]))),
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["languages"][values()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [ValuesCallableSubscript()]),
                    [ObjectIndexSubscript("languages")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ValuesCallableSubscript()]),
                            [ObjectIndexSubscript("languages")],
                        ),
                        root_value,
                        root_value["languages"],
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["preferences"][entries()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(),
                                  [EntriesCallableSubscript()]),
                    [ObjectIndexSubscript("preferences")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [EntriesCallableSubscript()]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        list(map(list, root_value["preferences"].items())),
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["preferences"][keys()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [KeysCallableSubscript()]),
                    [ObjectIndexSubscript("preferences")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [KeysCallableSubscript()]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        list(root_value["preferences"].keys()),
                    ),
                ],
            },
            {
                "__jsonpath__":
                '["preferences"][values()]',
                # pylint: disable=line-too-long
                "node":
                SubscriptNode(
                    SubscriptNode(TerminalNode(), [ValuesCallableSubscript()]),
                    [ObjectIndexSubscript("preferences")],
                ),  # noqa: E501
                # pylint: enable=line-too-long
                "root_value":
                root_value,
                "current_value":
                root_value,
                "match_data_list": [
                    MatchData(
                        SubscriptNode(
                            SubscriptNode(TerminalNode(),
                                          [ValuesCallableSubscript()]),
                            [ObjectIndexSubscript("preferences")],
                        ),
                        root_value,
                        list(root_value["preferences"].values()),
                    ),
                ],
            },
        ]