Ejemplo n.º 1
0
    def testCase100(self):
        n3 = { 'A': {'a0': { 'b0': { 'c0': 2 }, 'b1': {'c0': 3}, 'b2': {'c0': 4} }}}
        n4 = { 'B': {'a0': { 'b0': { 'c0': 2 }, 'b1': {'c0': 3}, 'b2': {'c0': 4} }}}
        n6 = { 'x0': { 'x1': { 'x2': n4 }} }
         
        sl6 = [ n3, n6, n4, ]
         
        p0 = JSONData.getPointerPath(n4['B']['a0']['b2'],sl6)
        resx = [[1, 'x0', 'x1', 'x2', 'B', 'a0', 'b2']]
        assert p0 == resx

        p0 = JSONData.getPointerPath(n4['B']['a0']['b2'],sl6,JSONData.FIRST)
        resx = [[1, 'x0', 'x1', 'x2', 'B', 'a0', 'b2']]
        assert p0 == resx
Ejemplo n.º 2
0
    def testCase100(self):
        c0 = {'c0': 4}
        n3 = {'A': {'a0': {'b0': c0, 'b1': {'c0': 3}, 'b2': c0}}}
        n4 = {'B': {'a0': {'b0': {'c0': 2}, 'b1': c0, 'b2': c0}}}
        n6 = {'x0': {'x1': {'x2': n4}}}
        n7 = {'y0': {'y1': n4}}
        n8 = {'y0': {'y1': c0}}

        sl6 = [
            n3,
            n6,
            n4,
            n7,
            n8,
        ]

        p0 = JSONData.getPointerPath(n4['B']['a0']['b2']['c0'], sl6,
                                     JSONData.ALL)
        resx = [[0, 'A', 'a0', 'b0', 'c0'], [0, 'A', 'a0', 'b2', 'c0'],
                [1, 'x0', 'x1', 'x2', 'B', 'a0', 'b1', 'c0'],
                [1, 'x0', 'x1', 'x2', 'B', 'a0', 'b2', 'c0'],
                [2, 'B', 'a0', 'b1', 'c0'], [2, 'B', 'a0', 'b2', 'c0'],
                [3, 'y0', 'y1', 'B', 'a0', 'b1', 'c0'],
                [3, 'y0', 'y1', 'B', 'a0', 'b2', 'c0'], [4, 'y0', 'y1', 'c0']]
        assert p0 == resx
Ejemplo n.º 3
0
    def testCase021(self):
        c0 = [4]

        n0 = [[{'c0': 'c0'}, {'c3': [3]}, ['c0']]]
        n1 = [[{'c0': c0}, {'c3': [3]}, ['c0']]]
        n2 = [[{'c0': 'c0'}, {'c3': [3]}, [c0]]]

        sl = [
            n0,
            n1,
            n2,
        ]

        p0 = JSONData.getPointerPath(c0, sl, JSONData.ALL)
        resx = [[1, 0, 0, 'c0'], [2, 0, 2, 0]]
        assert p0 == resx

        pathlst = []
        for rx in resx:
            pathlst.append(JSONPointer(rx).get_pointer())
        pathx = [
            u'/1/0/0/c0',
            u'/2/0/2/0',
        ]
        assert pathlst == pathx

        vallst = []
        for rx in resx:
            vallst.append(JSONPointer(rx).get_node_or_value(sl))
        vallstx = [
            [4],
            [4],
        ]
        assert vallst == vallstx
Ejemplo n.º 4
0
 def testCase100(self):
     n5 = [ 12 ]
     sl5 = [ n5, ]
     
     p0 = JSONData.getPointerPath(n5,sl5)
     resx = [[0]]
     assert p0 == resx
     pass
Ejemplo n.º 5
0
    def testCase110(self):
        n3 = [ [ [ [ 2 ], [ [ 3 ] ], [ [ 4 ] ] ] ] ]
        n4 = [ [ [ [ 3 ], [ [ 4 ] ], [ [ 5 ] ] ] ] ]
        sl4 = [ n3, n4, ]

        p0 = JSONData.getPointerPath(n4,sl4)
        resx = [[1]]
        assert p0 == resx
        pass
Ejemplo n.º 6
0
    def testCase110(self):
        n3 = { 'A': {'a0': { 'b0': { 'c0': 2 }, 'b1': {'c0': 3}, 'b2': {'c0': 4} }}}
        n4 = { 'B': {'a0': { 'b0': { 'c0': 2 }, 'b1': {'c0': 3}, 'b2': {'c0': 4} }}}
        sl4 = [ n3, n4, ]

        p0 = JSONData.getPointerPath(n4,sl4)
        resx = [[1]]
        assert p0 == resx
        pass
Ejemplo n.º 7
0
    def testCase100(self):
        c0 = [ 4 ]
        
        n3 = [ [ [ c0,    [ [ 3 ] ], [ c0 ] ] ] ]
        n4 = [ [ [ [ 3 ], [ c0 ],    [ c0 ] ] ] ]
        n6 = [ [ [ [ n4 ] ] ] ]
        n7 = [ [ n4 ] ]
        n8 = [ [ c0 ] ]

        sl6 = [ n3, n6, n4, n7, n8, ]

        p0 = JSONData.getPointerPath(n4[0][0][2][0],sl6,JSONData.ALL)
        resx = [
            [0, 0, 0, 0], 
            [0, 0, 0, 2, 0], 
            [1, 0, 0, 0, 0, 0, 0, 1, 0], 
            [1, 0, 0, 0, 0, 0, 0, 2, 0], 
            [2, 0, 0, 1, 0], 
            [2, 0, 0, 2, 0], 
            [3, 0, 0, 0, 0, 1, 0], 
            [3, 0, 0, 0, 0, 2, 0], 
            [4, 0, 0]
        ]
        assert p0 == resx
        
        pathlst = []
        for rx in resx:
            pathlst.append(JSONPointer(rx).get_pointer())
        pathx = [
            u'/0/0/0/0', 
            u'/0/0/0/2/0', 
            u'/1/0/0/0/0/0/0/1/0', 
            u'/1/0/0/0/0/0/0/2/0', 
            u'/2/0/0/1/0', 
            u'/2/0/0/2/0', 
            u'/3/0/0/0/0/1/0', 
            u'/3/0/0/0/0/2/0', 
            u'/4/0/0'
        ]
        assert pathlst == pathx
        
        vallst = []
        for rx in resx:
            vallst.append(JSONPointer(rx).get_node_or_value(sl6))
        vallstx = [
            [4],
            [4],
            [4],
            [4],
            [4],
            [4],
            [4],
            [4],
            [4]
        ]
        assert vallst == vallstx
Ejemplo n.º 8
0
    def testCase100(self):

        n3 = [[[[2], [[3]], [[4]]]]]
        n4 = [[[[3], [[4]], [[5]]]]]
        n6 = [[[[n3, n4]]]]
        sl6 = [
            n3,
            n6,
            n4,
        ]

        a = n4[0][0][2]
        assert n4[0][0][2] == [[5]]

        p0 = JSONData.getPointerPath(n4[0][0][2], n4)
        resx = [[0, 0, 2]]
        assert p0 == resx

        p0 = JSONData.getPointerPath(n4[0][0][2], sl6)
        resx = [[1, 0, 0, 0, 1, 0, 0, 2]]
        assert p0 == resx
Ejemplo n.º 9
0
    def testCase100(self):
        c0 = [ 4 ]
        
        n3 = [ [ [ 1,    [ [ 3 ] ],  [ c0 ] ] ] ]
        n4 = [ [ [ [ 3 ], [ c0 ],    [ c0 ] ] ] ]

        sl6 = [ n3, ]

        p0 = JSONData.getPointerPath(n4[0][0][2][0],sl6,JSONData.ALL)
        resx = [
            [0, 0, 0, 2, 0], 
        ]
        
        assert p0 == resx
Ejemplo n.º 10
0
    def testCase022(self):
        c0 = [4]

        n0 = [[{'c0': 'c0'}, {'c3': [3]}, ['c0']]]
        n1 = [[{'c0': c0}, {'c3': [3]}, ['c0']]]
        n2 = [[{'c0': 'c0'}, {'c3': [3]}, [c0]]]

        n3 = [[{'c0': c0}, {'c3': [3]}, [c0]]]
        n4 = {'x0': [[[3], {'c0': c0}, [c0]]]}
        n6 = [[[[n4]]]]
        n7 = [[n4]]
        n8 = {'x': {'c0': c0}}

        sl = [
            n0,
            n1,
            n2,
            n3,
            n6,
            n4,
            n7,
            n8,
        ]

        p0 = JSONData.getPointerPath(c0, sl, JSONData.ALL)
        resx = [[1, 0, 0, 'c0'], [2, 0, 2, 0], [3, 0, 0, 'c0'], [3, 0, 2, 0],
                [4, 0, 0, 0, 0, 'x0', 0, 1, 'c0'],
                [4, 0, 0, 0, 0, 'x0', 0, 2, 0], [5, 'x0', 0, 1, 'c0'],
                [5, 'x0', 0, 2, 0], [6, 0, 0, 'x0', 0, 1, 'c0'],
                [6, 0, 0, 'x0', 0, 2, 0], [7, 'x', 'c0']]
        assert p0 == resx

        pathlst = []
        for rx in resx:
            pathlst.append(JSONPointer(rx).get_pointer())
        pathx = [
            u'/1/0/0/c0', u'/2/0/2/0', u'/3/0/0/c0', u'/3/0/2/0',
            u'/4/0/0/0/0/x0/0/1/c0', u'/4/0/0/0/0/x0/0/2/0', u'/5/x0/0/1/c0',
            u'/5/x0/0/2/0', u'/6/0/0/x0/0/1/c0', u'/6/0/0/x0/0/2/0', u'/7/x/c0'
        ]
        assert pathlst == pathx

        vallst = []
        for rx in resx:
            vallst.append(JSONPointer(rx).get_node_or_value(sl))
        vallstx = [[4], [4], [4], [4], [4], [4], [4], [4], [4], [4], [4]]
        assert vallst == vallstx
Ejemplo n.º 11
0
    def testCase100(self):
        c0 = [4]

        n3 = [[{'c0': c0}, {'c3': [3]}, [c0]]]
        n4 = {'x0': [[[3], {'c0': c0}, [c0]]]}
        n6 = [[[[n4]]]]
        n7 = [[n4]]
        n8 = {'x': {'c0': c0}}

        sl6 = [
            n3,
            n6,
            n4,
            n7,
            n8,
        ]

        p0 = JSONData.getPointerPath(n4['x0'][0][2][0], sl6, JSONData.ALL)
        resx = [[0, 0, 0, 'c0'], [0, 0, 2, 0],
                [1, 0, 0, 0, 0, 'x0', 0, 1, 'c0'],
                [1, 0, 0, 0, 0, 'x0', 0, 2, 0], [2, 'x0', 0, 1, 'c0'],
                [2, 'x0', 0, 2, 0], [3, 0, 0, 'x0', 0, 1, 'c0'],
                [3, 0, 0, 'x0', 0, 2, 0], [4, 'x', 'c0']]
        assert p0 == resx

        pathlst = []
        for rx in resx:
            pathlst.append(JSONPointer(rx).get_pointer())
        pathx = [
            u'/0/0/0/c0', u'/0/0/2/0', u'/1/0/0/0/0/x0/0/1/c0',
            u'/1/0/0/0/0/x0/0/2/0', u'/2/x0/0/1/c0', u'/2/x0/0/2/0',
            u'/3/0/0/x0/0/1/c0', u'/3/0/0/x0/0/2/0', u'/4/x/c0'
        ]
        assert pathlst == pathx

        vallst = []
        for rx in resx:
            vallst.append(JSONPointer(rx).get_node_or_value(sl6))
        vallstx = [[4], [4], [4], [4], [4], [4], [4], [4], [4]]
        assert vallst == vallstx
Ejemplo n.º 12
0
    def testCase010(self):
        c0 = [4]

        n0 = [[{'c0': 'c0'}, {'c3': [3]}, ['c0']]]
        sl = [
            n0,
        ]

        p0 = JSONData.getPointerPath(c0, sl, JSONData.ALL)
        resx = []
        assert p0 == resx

        pathlst = []
        for rx in resx:
            pathlst.append(JSONPointer(rx).get_pointer())
        pathx = []
        assert pathlst == pathx

        vallst = []
        for rx in resx:
            vallst.append(JSONPointer(rx).get_node_or_value(sl))
        vallstx = []
        assert vallst == vallstx