示例#1
0
 def test_init_LocationPath_branch(self):
     lp = diffjson.LocationPath([
         diffjson.LocationStep(diffjson.NodenameRoot()),
         diffjson.LocationStep(diffjson.NodenameKey('key01')),
         diffjson.LocationStep(diffjson.NodenameKey('key02')),
         ])
     expected = 'key01/key02'
     assert str(lp.branch()) == expected
示例#2
0
 def test_init_LocationStepWithPredicates(self):
     plp = diffjson.LocationPath(
         [diffjson.LocationStep(diffjson.NodenameKey('key'))])
     p = diffjson.Predicate(plp, 'predicate')
     ps = diffjson.Predicates([p])
     l = diffjson.LocationStep(diffjson.NodenameRoot(), ps)
     expected = '/[key=predicate]'
     assert str(l) == expected
示例#3
0
 def test_init_LocationPath_current(self):
     lp = diffjson.LocationPath([
         diffjson.LocationStep(diffjson.NodenameRoot()),
         diffjson.LocationStep(diffjson.NodenameKey('key01')),
         diffjson.LocationStep(diffjson.NodenameKey('key02')),
         ])
     expected = '/'
     assert str(lp.current()) == expected
示例#4
0
    def test_parse_simple01(self):
        """
        Parser must parse input string and output appropriate LocationPath instance.

        """
        expected = diffjson.LocationPath([
            diffjson.LocationStep(diffjson.NodenameRoot()),
            diffjson.LocationStep(diffjson.NodenameKey('branch01')),
            diffjson.LocationStep(diffjson.NodenameKey('b01-01')),
        ])

        pathstring = '/branch01/b01-01'
        p = diffjson.parse(pathstring)

        assert p == expected
        assert str(p) == pathstring
示例#5
0
    def test_parse_with_self(self):
        """
        Parser with Self.

        """
        expected = diffjson.LocationPath([
            diffjson.LocationStep(diffjson.NodenameRoot()),
            diffjson.LocationStep(diffjson.NodenameKey('branch01')),
            diffjson.LocationStep(diffjson.NodenameSelf()),
            diffjson.LocationStep(diffjson.NodenameKey('b01-01')),
        ])

        pathstring = '/branch01/./b01-01'
        p = diffjson.parse(pathstring)

        assert p == expected
        assert str(p) == pathstring
示例#6
0
    def test_parse_with_decendant(self):
        """
        Parser with Descendant.

        """
        expected = diffjson.LocationPath([
            diffjson.LocationStep(diffjson.NodenameRoot()),
            diffjson.LocationStep(diffjson.NodenameKey('branch01')),
            diffjson.LocationStep(diffjson.NodenameDescendant()),
            diffjson.LocationStep(diffjson.NodenameKey('branch01-01-01')),
        ])

        pathstring = '/branch01//branch01-01-01'
        p = diffjson.parse(pathstring)

        assert p == expected
        assert str(p) == pathstring
示例#7
0
 def test_init_Predicate(self):
     plp = diffjson.LocationPath(
         [diffjson.LocationStep(diffjson.NodenameKey('key'))])
     p = diffjson.Predicate(plp, 'predicate')
     expected = 'key=predicate'
     assert str(p) == expected
示例#8
0
 def test_init_LocationPath(self):
     lp = diffjson.LocationPath(
         [diffjson.LocationStep(diffjson.NodenameRoot())])
     expected = '/'
     assert str(lp) == expected
示例#9
0
 def test_init_LocationStep(self):
     l = diffjson.LocationStep(diffjson.NodenameRoot())
     expected = '/'
     assert str(l) == expected