@@ -368,6 +368,17 @@ def test_issue40(self):
368
368
dest = [7 , 2 , 1 , 0 , 9 , 4 , 3 , 6 , 5 , 8 ]
369
369
patch = jsonpatch .make_patch (src , dest )
370
370
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
+
371
382
def test_json_patch (self ):
372
383
old = {
373
384
'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):
424
435
dst = {'foo' : [{'bar' : 1 }, {'bar' : 2 , 'baz' : 3 }]}
425
436
patch = list (jsonpatch .make_patch (src , dst ))
426
437
427
- exp = [{'op' : 'remove' , 'value' : 2 , ' path' : '/foo/0/baz' }]
438
+ exp = [{'op' : 'remove' , 'path' : '/foo/0/baz' }]
428
439
self .assertEqual (patch , exp )
429
440
430
441
res = jsonpatch .apply_patch (src , patch )
@@ -481,11 +492,14 @@ def test_success_if_correct_expected_patch_appied(self):
481
492
src = [{"a" : 1 , "b" : 2 }]
482
493
dst = [{"b" : 2 , "c" : 2 }]
483
494
exp = [
484
- {'path' : '/0/a' , 'op' : 'remove' , 'value' : 1 },
495
+ {'path' : '/0/a' , 'op' : 'remove' },
485
496
{'path' : '/0/c' , 'op' : 'add' , 'value' : 2 }
486
497
]
487
498
patch = jsonpatch .make_patch (src , dst )
488
499
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 )
489
503
490
504
def test_minimal_patch (self ):
491
505
""" Test whether a minimal patch is created, see #36 """
0 commit comments