@@ -368,6 +368,17 @@ def test_issue40(self):
368368 dest = [7 , 2 , 1 , 0 , 9 , 4 , 3 , 6 , 5 , 8 ]
369369 patch = jsonpatch .make_patch (src , dest )
370370
371+ def test_issue76 (self ):
372+ """ Make sure op:remove does not include a 'value' field """
373+
374+ src = { "name" : "fred" , "friend" : "barney" , "spouse" : "wilma" }
375+ dst = { "name" : "fred" , "spouse" : "wilma" }
376+ expected = [{"path" : "/friend" , "op" : "remove" }]
377+ patch = jsonpatch .make_patch (src , dst )
378+ self .assertEqual (patch .patch , expected )
379+ res = jsonpatch .apply_patch (src , patch )
380+ self .assertEqual (res , dst )
381+
371382 def test_json_patch (self ):
372383 old = {
373384 'queue' : {'teams_out' : [{'id' : 3 , 'reason' : 'If tied' }, {'id' : 5 , 'reason' : 'If tied' }]},
@@ -424,7 +435,7 @@ def test_use_replace_instead_of_remove_add_nested(self):
424435 dst = {'foo' : [{'bar' : 1 }, {'bar' : 2 , 'baz' : 3 }]}
425436 patch = list (jsonpatch .make_patch (src , dst ))
426437
427- exp = [{'op' : 'remove' , 'value' : 2 , ' path' : '/foo/0/baz' }]
438+ exp = [{'op' : 'remove' , 'path' : '/foo/0/baz' }]
428439 self .assertEqual (patch , exp )
429440
430441 res = jsonpatch .apply_patch (src , patch )
@@ -481,11 +492,14 @@ def test_success_if_correct_expected_patch_appied(self):
481492 src = [{"a" : 1 , "b" : 2 }]
482493 dst = [{"b" : 2 , "c" : 2 }]
483494 exp = [
484- {'path' : '/0/a' , 'op' : 'remove' , 'value' : 1 },
495+ {'path' : '/0/a' , 'op' : 'remove' },
485496 {'path' : '/0/c' , 'op' : 'add' , 'value' : 2 }
486497 ]
487498 patch = jsonpatch .make_patch (src , dst )
488499 self .assertEqual (patch .patch , exp )
500+ # verify that this patch does what we expect
501+ res = jsonpatch .apply_patch (src , patch )
502+ self .assertEqual (res , dst )
489503
490504 def test_minimal_patch (self ):
491505 """ Test whether a minimal patch is created, see #36 """
0 commit comments