@@ -73,8 +73,8 @@ def test_list_difference_add_delta(self):
73
73
74
74
flat_result1 = delta .to_flat_rows ()
75
75
flat_expected1 = [
76
- FlatDeltaRow (path = [3 ], value = 5 , action = 'iterable_item_added' ),
77
- FlatDeltaRow (path = [2 ], value = 3 , action = 'iterable_item_added' ),
76
+ FlatDeltaRow (path = [3 ], value = 5 , action = 'iterable_item_added' , type = int ),
77
+ FlatDeltaRow (path = [2 ], value = 3 , action = 'iterable_item_added' , type = int ),
78
78
]
79
79
80
80
assert flat_expected1 == flat_result1
@@ -291,9 +291,9 @@ def test_list_difference3_delta(self):
291
291
292
292
flat_result1 = delta .to_flat_rows ()
293
293
flat_expected1 = [
294
- FlatDeltaRow (path = [4 , 'b' , 2 ], action = 'values_changed' , value = 2 , old_value = 5 ),
295
- FlatDeltaRow (path = [4 , 'b' , 1 ], action = 'values_changed' , value = 3 , old_value = 2 ),
296
- FlatDeltaRow (path = [4 , 'b' , 3 ], value = 5 , action = 'iterable_item_added' ),
294
+ FlatDeltaRow (path = [4 , 'b' , 2 ], action = 'values_changed' , value = 2 , old_value = 5 , type = int , old_type = int ),
295
+ FlatDeltaRow (path = [4 , 'b' , 1 ], action = 'values_changed' , value = 3 , old_value = 2 , type = int , old_type = int ),
296
+ FlatDeltaRow (path = [4 , 'b' , 3 ], value = 5 , action = 'iterable_item_added' , type = int ),
297
297
]
298
298
299
299
assert flat_expected1 == flat_result1
@@ -332,9 +332,9 @@ def test_list_difference_delta_raises_error_if_prev_value_does_not_match(self):
332
332
333
333
flat_result2 = delta2 .to_flat_rows ()
334
334
flat_expected2 = [
335
- FlatDeltaRow (path = [2 ], action = 'values_changed' , value = 2 , old_value = 5 ),
336
- FlatDeltaRow (path = [1 ], action = 'values_changed' , value = 3 , old_value = 2 ),
337
- FlatDeltaRow (path = [3 ], value = 5 , action = 'iterable_item_added' ),
335
+ FlatDeltaRow (path = [2 ], action = 'values_changed' , value = 2 , old_value = 5 , type = int , old_type = int ),
336
+ FlatDeltaRow (path = [1 ], action = 'values_changed' , value = 3 , old_value = 2 , type = int , old_type = int ),
337
+ FlatDeltaRow (path = [3 ], value = 5 , action = 'iterable_item_added' , type = int ),
338
338
]
339
339
340
340
assert flat_expected2 == flat_result2
@@ -363,8 +363,8 @@ def test_list_difference_delta1(self):
363
363
364
364
flat_result = delta .to_flat_rows ()
365
365
flat_expected = [
366
- FlatDeltaRow (path = [4 , 'b' , 2 ], value = 'to_be_removed' , action = 'iterable_item_removed' ),
367
- FlatDeltaRow (path = [4 , 'b' , 3 ], value = 'to_be_removed2' , action = 'iterable_item_removed' ),
366
+ FlatDeltaRow (path = [4 , 'b' , 2 ], value = 'to_be_removed' , action = 'iterable_item_removed' , type = str ),
367
+ FlatDeltaRow (path = [4 , 'b' , 3 ], value = 'to_be_removed2' , action = 'iterable_item_removed' , type = str ),
368
368
]
369
369
370
370
assert flat_expected == flat_result
@@ -567,7 +567,8 @@ def compare_func(item1, item2, level=None):
567
567
'professionalDesignation' : '' ,
568
568
'suffix' : 'SR' ,
569
569
'nameIdentifier' : '00003' },
570
- action = 'unordered_iterable_item_added' ),
570
+ action = 'unordered_iterable_item_added' ,
571
+ type = dict ),
571
572
FlatDeltaRow (path = ['individualNames' , 1 ],
572
573
value = {'firstName' : 'John' ,
573
574
'lastName' : 'Doe' ,
@@ -577,7 +578,9 @@ def compare_func(item1, item2, level=None):
577
578
'professionalDesignation' : '' ,
578
579
'suffix' : 'SR' ,
579
580
'nameIdentifier' : '00002' },
580
- action = 'unordered_iterable_item_removed' )]
581
+ action = 'unordered_iterable_item_removed' ,
582
+ type = dict ),
583
+ ]
581
584
582
585
preserved_flat_dict_list = copy .deepcopy (flat_rows_list ) # Use this later for assert comparison
583
586
@@ -1405,13 +1408,13 @@ def test_list_ignore_order_various_deltas2(self):
1405
1408
1406
1409
flat_result1 = delta1 .to_flat_rows ()
1407
1410
flat_expected1 = [
1408
- {'path' : [0 ], 'value' : 7 , 'action' : 'unordered_iterable_item_added' },
1409
- {'path' : [6 ], 'value' : 8 , 'action' : 'unordered_iterable_item_added' },
1410
- {'path' : [1 ], 'value' : 4 , 'action' : 'unordered_iterable_item_added' },
1411
- {'path' : [2 ], 'value' : 4 , 'action' : 'unordered_iterable_item_added' },
1412
- {'path' : [5 ], 'value' : 4 , 'action' : 'unordered_iterable_item_added' },
1413
- {'path' : [6 ], 'value' : 6 , 'action' : 'unordered_iterable_item_removed' },
1414
- {'path' : [0 ], 'value' : 5 , 'action' : 'unordered_iterable_item_removed' },
1411
+ {'path' : [0 ], 'value' : 7 , 'action' : 'unordered_iterable_item_added' , 'type' : int },
1412
+ {'path' : [6 ], 'value' : 8 , 'action' : 'unordered_iterable_item_added' , 'type' : int },
1413
+ {'path' : [1 ], 'value' : 4 , 'action' : 'unordered_iterable_item_added' , 'type' : int },
1414
+ {'path' : [2 ], 'value' : 4 , 'action' : 'unordered_iterable_item_added' , 'type' : int },
1415
+ {'path' : [5 ], 'value' : 4 , 'action' : 'unordered_iterable_item_added' , 'type' : int },
1416
+ {'path' : [6 ], 'value' : 6 , 'action' : 'unordered_iterable_item_removed' , 'type' : int },
1417
+ {'path' : [0 ], 'value' : 5 , 'action' : 'unordered_iterable_item_removed' , 'type' : int },
1415
1418
]
1416
1419
flat_expected1 = [FlatDeltaRow (** i ) for i in flat_expected1 ]
1417
1420
assert flat_expected1 == flat_result1
@@ -1422,11 +1425,11 @@ def test_list_ignore_order_various_deltas2(self):
1422
1425
1423
1426
flat_result2 = delta2 .to_flat_rows ()
1424
1427
flat_expected2 = [
1425
- {'path' : [1 ], 'value' : 4 , 'action' : 'unordered_iterable_item_added' },
1426
- {'path' : [2 ], 'value' : 4 , 'action' : 'unordered_iterable_item_added' },
1427
- {'path' : [5 ], 'value' : 4 , 'action' : 'unordered_iterable_item_added' },
1428
- {'path' : [6 ], 'action' : 'values_changed' , 'value' : 7 },
1429
- {'path' : [0 ], 'action' : 'values_changed' , 'value' : 8 },
1428
+ {'path' : [1 ], 'value' : 4 , 'action' : 'unordered_iterable_item_added' , 'type' : int },
1429
+ {'path' : [2 ], 'value' : 4 , 'action' : 'unordered_iterable_item_added' , 'type' : int },
1430
+ {'path' : [5 ], 'value' : 4 , 'action' : 'unordered_iterable_item_added' , 'type' : int },
1431
+ {'path' : [6 ], 'action' : 'values_changed' , 'value' : 7 , 'type' : int },
1432
+ {'path' : [0 ], 'action' : 'values_changed' , 'value' : 8 , 'type' : int },
1430
1433
]
1431
1434
flat_expected2 = [FlatDeltaRow (** i ) for i in flat_expected2 ]
1432
1435
assert flat_expected2 == flat_result2
@@ -1565,7 +1568,7 @@ def test_apply_delta_to_incompatible_object6_value_change(self):
1565
1568
assert [] == t4
1566
1569
1567
1570
flat_result2 = delta2 .to_flat_rows ()
1568
- flat_expected2 = [{'path' : [1 , 2 , 0 ], 'action' : 'values_changed' , 'value' : 5 }]
1571
+ flat_expected2 = [{'path' : [1 , 2 , 0 ], 'action' : 'values_changed' , 'value' : 5 , 'type' : int }]
1569
1572
flat_expected2 = [FlatDeltaRow (** i ) for i in flat_expected2 ]
1570
1573
1571
1574
assert flat_expected2 == flat_result2
@@ -1575,7 +1578,7 @@ def test_apply_delta_to_incompatible_object6_value_change(self):
1575
1578
1576
1579
delta3 = Delta (diff , raise_errors = False , bidirectional = True )
1577
1580
flat_result3 = delta3 .to_flat_rows ()
1578
- flat_expected3 = [{'path' : [1 , 2 , 0 ], 'action' : 'values_changed' , 'value' : 5 , 'old_value' : 4 }]
1581
+ flat_expected3 = [{'path' : [1 , 2 , 0 ], 'action' : 'values_changed' , 'value' : 5 , 'old_value' : 4 , 'type' : int , 'old_type' : int }]
1579
1582
flat_expected3 = [FlatDeltaRow (** i ) for i in flat_expected3 ]
1580
1583
1581
1584
assert flat_expected3 == flat_result3
@@ -1685,7 +1688,7 @@ def test_delta_to_dict(self):
1685
1688
assert expected == result
1686
1689
1687
1690
flat_result = delta .to_flat_rows ()
1688
- flat_expected = [{'action' : 'unordered_iterable_item_removed' , 'path' : [2 ], 'value' : 'B' }]
1691
+ flat_expected = [{'action' : 'unordered_iterable_item_removed' , 'path' : [2 ], 'value' : 'B' , 'type' : str }]
1689
1692
flat_expected = [FlatDeltaRow (** i ) for i in flat_expected ]
1690
1693
1691
1694
assert flat_expected == flat_result
@@ -1766,10 +1769,10 @@ def test_delta_set_in_objects(self):
1766
1769
delta = Delta (DeepDiff (t1 , t2 ))
1767
1770
flat_result = delta .to_flat_rows ()
1768
1771
flat_expected = [
1769
- {'path' : [0 , 1 ], 'value' : 10 , 'action' : 'set_item_added' },
1770
- {'path' : [0 , 0 ], 'action' : 'values_changed' , 'value' : 2 },
1771
- {'path' : [0 , 1 ], 'value' : 'A' , 'action' : 'set_item_removed' },
1772
- {'path' : [0 , 1 ], 'value' : 'C' , 'action' : 'set_item_added' },
1772
+ {'path' : [0 , 1 ], 'value' : 10 , 'action' : 'set_item_added' , 'type' : int },
1773
+ {'path' : [0 , 0 ], 'action' : 'values_changed' , 'value' : 2 , 'type' : int },
1774
+ {'path' : [0 , 1 ], 'value' : 'A' , 'action' : 'set_item_removed' , 'type' : str },
1775
+ {'path' : [0 , 1 ], 'value' : 'C' , 'action' : 'set_item_added' , 'type' : str },
1773
1776
]
1774
1777
flat_expected = [FlatDeltaRow (** i ) for i in flat_expected ]
1775
1778
@@ -1885,11 +1888,11 @@ def test_compare_func_with_duplicates_removed(self):
1885
1888
1886
1889
flat_result = delta .to_flat_rows ()
1887
1890
flat_expected = [
1888
- {'path' : [2 ], 'value' : {'id' : 1 , 'val' : 3 }, 'action' : 'iterable_item_removed' },
1889
- {'path' : [0 ], 'value' : {'id' : 1 , 'val' : 3 }, 'action' : 'iterable_item_removed' },
1890
- {'path' : [3 ], 'value' : {'id' : 3 , 'val' : 3 }, 'action' : 'iterable_item_removed' },
1891
- {'path' : [0 ], 'action' : 'iterable_item_moved' , 'value' : {'id' : 1 , 'val' : 3 }, 'new_path' : [2 ]},
1892
- {'path' : [3 ], 'action' : 'iterable_item_moved' , 'value' : {'id' : 3 , 'val' : 3 }, 'new_path' : [0 ]},
1891
+ {'path' : [2 ], 'value' : {'id' : 1 , 'val' : 3 }, 'action' : 'iterable_item_removed' , 'type' : dict },
1892
+ {'path' : [0 ], 'value' : {'id' : 1 , 'val' : 3 }, 'action' : 'iterable_item_removed' , 'type' : dict },
1893
+ {'path' : [3 ], 'value' : {'id' : 3 , 'val' : 3 }, 'action' : 'iterable_item_removed' , 'type' : dict },
1894
+ {'path' : [0 ], 'action' : 'iterable_item_moved' , 'value' : {'id' : 1 , 'val' : 3 }, 'new_path' : [2 ], 'type' : dict },
1895
+ {'path' : [3 ], 'action' : 'iterable_item_moved' , 'value' : {'id' : 3 , 'val' : 3 }, 'new_path' : [0 ], 'type' : dict },
1893
1896
]
1894
1897
flat_expected = [FlatDeltaRow (** i ) for i in flat_expected ]
1895
1898
@@ -2289,11 +2292,13 @@ def test_subtract_delta_made_from_flat_dicts1(self):
2289
2292
expected_flat_dicts = [{
2290
2293
'path' : ['field_name1' , 0 ],
2291
2294
'value' : 'xxx' ,
2292
- 'action' : 'iterable_item_removed'
2295
+ 'action' : 'iterable_item_removed' ,
2296
+ 'type' : str ,
2293
2297
}, {
2294
2298
'path' : ['field_name1' , 1 ],
2295
2299
'value' : 'yyy' ,
2296
- 'action' : 'iterable_item_removed'
2300
+ 'action' : 'iterable_item_removed' ,
2301
+ 'type' : str ,
2297
2302
}]
2298
2303
expected_flat_dicts = [FlatDeltaRow (** i ) for i in expected_flat_dicts ]
2299
2304
@@ -2318,11 +2323,13 @@ def test_subtract_delta_made_from_flat_dicts2(self):
2318
2323
expected_flat_dicts = [{
2319
2324
'path' : ['field_name1' , 0 ],
2320
2325
'value' : 'xxx' ,
2321
- 'action' : 'iterable_item_added'
2326
+ 'action' : 'iterable_item_added' ,
2327
+ 'type' : str ,
2322
2328
}, {
2323
2329
'path' : ['field_name1' , 1 ],
2324
2330
'value' : 'yyy' ,
2325
- 'action' : 'iterable_item_added'
2331
+ 'action' : 'iterable_item_added' ,
2332
+ 'type' : str ,
2326
2333
}]
2327
2334
expected_flat_dicts = [FlatDeltaRow (** i ) for i in expected_flat_dicts ]
2328
2335
0 commit comments