@@ -594,6 +594,27 @@ def test_replace_missing(self):
594
594
self .assertRaises (jsonpatch .JsonPatchConflict , jsonpatch .apply_patch , src , patch_obj )
595
595
596
596
597
+ class JsonPointerTests (unittest .TestCase ):
598
+
599
+ def test_create_with_pointer (self ):
600
+
601
+ patch = jsonpatch .JsonPatch ([
602
+ {'op' : 'add' , 'path' : jsonpointer .JsonPointer ('/foo' ), 'value' : 'bar' },
603
+ {'op' : 'add' , 'path' : jsonpointer .JsonPointer ('/baz' ), 'value' : [1 , 2 , 3 ]},
604
+ {'op' : 'remove' , 'path' : jsonpointer .JsonPointer ('/baz/1' )},
605
+ {'op' : 'test' , 'path' : jsonpointer .JsonPointer ('/baz' ), 'value' : [1 , 3 ]},
606
+ {'op' : 'replace' , 'path' : jsonpointer .JsonPointer ('/baz/0' ), 'value' : 42 },
607
+ {'op' : 'remove' , 'path' : jsonpointer .JsonPointer ('/baz/1' )},
608
+ {'op' : 'move' , 'from' : jsonpointer .JsonPointer ('/foo' ), 'path' : jsonpointer .JsonPointer ('/bar' )},
609
+
610
+ ])
611
+ doc = {}
612
+ result = patch .apply (doc )
613
+ expected = {'bar' : 'bar' , 'baz' : [42 ]}
614
+ self .assertEqual (result , expected )
615
+
616
+
617
+
597
618
if __name__ == '__main__' :
598
619
modules = ['jsonpatch' ]
599
620
@@ -608,6 +629,7 @@ def get_suite():
608
629
suite .addTest (unittest .makeSuite (InvalidInputTests ))
609
630
suite .addTest (unittest .makeSuite (ConflictTests ))
610
631
suite .addTest (unittest .makeSuite (OptimizationTests ))
632
+ suite .addTest (unittest .makeSuite (JsonPointerTests ))
611
633
return suite
612
634
613
635
0 commit comments