@@ -738,6 +738,44 @@ def test_make_patch(self):
738
738
self .assertEqual (op .pointer_cls , CustomJsonPointer )
739
739
740
740
def test_operations (self ):
741
+ operations = [
742
+ (
743
+ jsonpatch .AddOperation , {
744
+ 'op' : 'add' , 'path' : '/foo' , 'value' : [1 , 2 , 3 ]
745
+ }
746
+ ),
747
+ (
748
+ jsonpatch .MoveOperation , {
749
+ 'op' : 'move' , 'path' : '/baz' , 'from' : '/foo'
750
+ },
751
+ ),
752
+ (
753
+ jsonpatch .RemoveOperation , {
754
+ 'op' : 'remove' , 'path' : '/baz/1'
755
+ },
756
+ ),
757
+ (
758
+ jsonpatch .TestOperation , {
759
+ 'op' : 'test' , 'path' : '/baz' , 'value' : [1 , 3 ]
760
+ },
761
+ ),
762
+ (
763
+ jsonpatch .ReplaceOperation , {
764
+ 'op' : 'replace' , 'path' : '/baz/0' , 'value' : 42
765
+ },
766
+ ),
767
+ (
768
+ jsonpatch .RemoveOperation , {
769
+ 'op' : 'remove' , 'path' : '/baz/1'
770
+ },
771
+ )
772
+ ]
773
+ for cls , patch in operations :
774
+ operation = cls (patch , pointer_cls = CustomJsonPointer )
775
+ self .assertEqual (operation .pointer_cls , CustomJsonPointer )
776
+ self .assertIsInstance (operation .pointer , CustomJsonPointer )
777
+
778
+ def test_operations_from_patch (self ):
741
779
patch = jsonpatch .JsonPatch ([
742
780
{'op' : 'add' , 'path' : '/foo' , 'value' : [1 , 2 , 3 ]},
743
781
{'op' : 'move' , 'path' : '/baz' , 'from' : '/foo' },
0 commit comments