@@ -608,6 +608,27 @@ def test_replace_missing(self):
608608 self .assertRaises (jsonpatch .JsonPatchConflict , jsonpatch .apply_patch , src , patch_obj )
609609
610610
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+
611632if __name__ == '__main__' :
612633 modules = ['jsonpatch' ]
613634
@@ -622,6 +643,7 @@ def get_suite():
622643 suite .addTest (unittest .makeSuite (InvalidInputTests ))
623644 suite .addTest (unittest .makeSuite (ConflictTests ))
624645 suite .addTest (unittest .makeSuite (OptimizationTests ))
646+ suite .addTest (unittest .makeSuite (JsonPointerTests ))
625647 return suite
626648
627649
0 commit comments