@@ -594,6 +594,27 @@ def test_replace_missing(self):
594594 self .assertRaises (jsonpatch .JsonPatchConflict , jsonpatch .apply_patch , src , patch_obj )
595595
596596
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+
597618if __name__ == '__main__' :
598619 modules = ['jsonpatch' ]
599620
@@ -608,6 +629,7 @@ def get_suite():
608629 suite .addTest (unittest .makeSuite (InvalidInputTests ))
609630 suite .addTest (unittest .makeSuite (ConflictTests ))
610631 suite .addTest (unittest .makeSuite (OptimizationTests ))
632+ suite .addTest (unittest .makeSuite (JsonPointerTests ))
611633 return suite
612634
613635
0 commit comments