@@ -608,6 +608,27 @@ def test_replace_missing(self):
608
608
self .assertRaises (jsonpatch .JsonPatchConflict , jsonpatch .apply_patch , src , patch_obj )
609
609
610
610
611
+ class JsonPointerTests (unittest .TestCase ):
612
+
613
+ def test_create_with_pointer (self ):
614
+
615
+ patch = jsonpatch .JsonPatch ([
616
+ {'op' : 'add' , 'path' : jsonpointer .JsonPointer ('/foo' ), 'value' : 'bar' },
617
+ {'op' : 'add' , 'path' : jsonpointer .JsonPointer ('/baz' ), 'value' : [1 , 2 , 3 ]},
618
+ {'op' : 'remove' , 'path' : jsonpointer .JsonPointer ('/baz/1' )},
619
+ {'op' : 'test' , 'path' : jsonpointer .JsonPointer ('/baz' ), 'value' : [1 , 3 ]},
620
+ {'op' : 'replace' , 'path' : jsonpointer .JsonPointer ('/baz/0' ), 'value' : 42 },
621
+ {'op' : 'remove' , 'path' : jsonpointer .JsonPointer ('/baz/1' )},
622
+ {'op' : 'move' , 'from' : jsonpointer .JsonPointer ('/foo' ), 'path' : jsonpointer .JsonPointer ('/bar' )},
623
+
624
+ ])
625
+ doc = {}
626
+ result = patch .apply (doc )
627
+ expected = {'bar' : 'bar' , 'baz' : [42 ]}
628
+ self .assertEqual (result , expected )
629
+
630
+
631
+
611
632
if __name__ == '__main__' :
612
633
modules = ['jsonpatch' ]
613
634
@@ -622,6 +643,7 @@ def get_suite():
622
643
suite .addTest (unittest .makeSuite (InvalidInputTests ))
623
644
suite .addTest (unittest .makeSuite (ConflictTests ))
624
645
suite .addTest (unittest .makeSuite (OptimizationTests ))
646
+ suite .addTest (unittest .makeSuite (JsonPointerTests ))
625
647
return suite
626
648
627
649
0 commit comments