Ejemplo n.º 1
0
 def test_diff_array_append_conflict(self):
     a = ['foo']
     b = ['foo', 'bar']
     c = ['foo', 'baz']
     conflict = Conflict(Diff(a, b), Diff(a, c))
     # self.assertEquals(('bar', 'baz'), conflict[1].append)
     self.assertEquals({1: ('bar', 'baz')}, conflict.append)
Ejemplo n.º 2
0
 def xtest_diff_array_nested_update_conflict(self):
     a = ['boo', ['foo', 'bar']]
     b = ['boo', ['foo', 'baz']]
     c = ['boo', ['foo', 'bazzz']]
     conflict = Conflict(Diff(a, b), Diff(a, c))
     # self.assertEquals(('baz', 'bazzz'), conflict[1].update)
     self.assertEquals({1: ('baz', 'bazzz')}, conflict.update)
Ejemplo n.º 3
0
 def test_diff_dict_remove_conflict(self):
     a = {'roses': 'red', 'violets': 'blue'}
     b = {'roses': 'red', 'violets': 'magenta'}
     c = {'roses': 'red'}
     conflict = Conflict(Diff(a, b), Diff(a, c))
     self.assertEquals({'violets': ('magenta', None)}, conflict.update)
     self.assertEquals({'violets': (None, 'blue')}, conflict.remove)
Ejemplo n.º 4
0
 def test_no_changes(self):
     for f in self.fixtures:
         diff = Diff(f, f)
         self.assertIsNone(diff.replace)
         self.assertIsNone(diff.update)
         self.assertIsNone(diff.remove)
         self.assertIsNone(diff.append)
         self.assertEquals(f, diff.apply(f))
Ejemplo n.º 5
0
 def test_no_changes(self):
     for f in self.fixtures:
         diff = Diff(f, f)
         self.assertIsNone(diff.replace)
         self.assertIsNone(diff.update)
         self.assertIsNone(diff.remove)
         self.assertIsNone(diff.append)
         self.assertEquals(f, diff.apply(f))
Ejemplo n.º 6
0
 def test_diff_empty_dict(self):
     """json_diff bugs out on empty dicts normally.
     """
     a = {}
     b = {'key': 'value'}
     diff = Diff(a, b)
     self.assertEquals({'key': 'value'}, diff.append)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 7
0
 def test_diff_empty_dict(self):
     """json_diff bugs out on empty dicts normally.
     """
     a = {}
     b = {'key': 'value'}
     diff = Diff(a, b)
     self.assertEquals({'key': 'value'}, diff.append)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 8
0
 def test_diff_array_remove_conflict(self):
     a = ['foo', 'bar']
     b = ['foo', 'baz']
     c = ['foo']
     conflict = Conflict(Diff(a, b), Diff(a, c))
     # self.assertEquals(('baz', None), conflict[1].update)
     # self.assertEquals((None, 'bar'), conflict[1].remove)
     self.assertEquals({1: ('baz', None)}, conflict.update)
     self.assertEquals({1: (None, 'bar')}, conflict.remove)
Ejemplo n.º 9
0
 def test_diff_array_nested_remove(self):
     a = ['foo', ['bar', 'baz']]
     b = ['foo', ['bar']]
     diff = Diff(a, b)
     self.assertEquals({1: 'baz'}, diff.update[1].remove)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 10
0
 def test_diff_array_remove(self):
     a = ['foo', 'bar']
     b = ['foo']
     diff = Diff(a, b)
     self.assertEquals({1: 'bar'}, diff.remove)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 11
0
 def test_diff_dict_nested_remove(self):
     a = {'flowers': {'roses': 'red', 'violets': 'blue'}}
     b = {'flowers': {'roses': 'red'}}
     diff = Diff(a, b)
     self.assertEquals({'violets': 'blue'}, diff.update['flowers'].remove)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 12
0
 def test_diff_dict_nested_remove(self):
     a = {'flowers': {'roses': 'red', 'violets': 'blue'}}
     b = {'flowers': {'roses': 'red'}}
     diff = Diff(a, b)
     self.assertEquals({'violets': 'blue'}, diff.update['flowers'].remove)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 13
0
 def test_diff_dict_append_conflict(self):
     a = {'roses': 'red'}
     b = {'roses': 'red', 'violets': 'blue'}
     c = {'roses': 'red', 'violets': 'magenta'}
     conflict = Conflict(Diff(a, b), Diff(a, c))
     self.assertEquals({'violets': ('blue', 'magenta')}, conflict.append)
Ejemplo n.º 14
0
 def test_diff_dict_update_conflict(self):
     a = {'roses': 'red'}
     b = {'roses': 'blue'}
     c = {'roses': 'white'}
     conflict = Conflict(Diff(a, b), Diff(a, c))
     self.assertEquals({'roses': ('blue', 'white')}, conflict.update)
Ejemplo n.º 15
0
 def xtest_diff_scalar_replace_no_conflict(self):
     a = 'foo'
     b = 'bar'
     c = 'bar'
     conflict = Conflict(Diff(a, b), Diff(a, c))
     self.assertFalse(conflict)
Ejemplo n.º 16
0
 def xtest_diff_array_nested_append_conflict(self):
     a = ['boo', ['foo']]
     b = ['boo', ['foo', 'bar']]
     c = ['boo', ['foo', 'baz']]
     conflict = Conflict(Diff(a, b), Diff(a, c))
     self.assertEquals({1: ('bar', 'baz')}, conflict.update[1].append)
Ejemplo n.º 17
0
 def test_diff_different_types_favor_second(self):
     for a, b in itertools.permutations(self.fixtures, 2):
         diff = Diff(a, b)
         self.assertEquals(b, diff.replace)
         self.assertEquals(b, diff.apply(a))
Ejemplo n.º 18
0
 def test_diff_dict_append(self):
     a = {'roses': 'red'}
     b = {'roses': 'red', 'violets': 'blue'}
     diff = Diff(a, b)
     self.assertEquals({'violets': 'blue'}, diff.append)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 19
0
 def test_diff_strings(self):
     a = 'foo'
     b = 'bar'
     diff = Diff(a, b)
     self.assertEquals('bar', diff.replace)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 20
0
 def test_diff_dict_update(self):
     a = {'roses': 'red', 'violets': 'blue'}
     b = {'roses': 'red', 'violets': 'aqua'}
     diff = Diff(a, b)
     self.assertEquals({'violets': 'aqua'}, diff.update)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 21
0
 def test_diff_array_remove(self):
     a = ['foo', 'bar']
     b = ['foo']
     diff = Diff(a, b)
     self.assertEquals({1: 'bar'}, diff.remove)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 22
0
 def test_diff_different_types_favor_second(self):
     for a, b in itertools.permutations(self.fixtures, 2):
         diff = Diff(a, b)
         self.assertEquals(b, diff.replace)
         self.assertEquals(b, diff.apply(a))
Ejemplo n.º 23
0
 def test_diff_scalar_replace_conflict(self):
     a = 'foo'
     b = 'bar'
     c = 'baz'
     conflict = Conflict(Diff(a, b), Diff(a, c))
     self.assertEquals(('bar', 'baz'), conflict.replace)
Ejemplo n.º 24
0
 def test_diff_numbers(self):
     a = 4
     b = 7
     diff = Diff(a, b)
     self.assertEquals(7, diff.replace)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 25
0
 def test_diff_numbers(self):
     a = 4
     b = 7
     diff = Diff(a, b)
     self.assertEquals(7, diff.replace)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 26
0
 def test_diff_array_update(self):
     a = ['foo', 'bar']
     b = ['foo', 'baz']
     diff = Diff(a, b)
     self.assertEquals({1: 'baz'}, diff.update)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 27
0
 def test_diff_strings(self):
     a = 'foo'
     b = 'bar'
     diff = Diff(a, b)
     self.assertEquals('bar', diff.replace)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 28
0
 def test_diff_array_nested_remove(self):
     a = ['foo', ['bar', 'baz']]
     b = ['foo', ['bar']]
     diff = Diff(a, b)
     self.assertEquals({1: 'baz'}, diff.update[1].remove)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 29
0
 def test_diff_array_update(self):
     a = ['foo', 'bar']
     b = ['foo', 'baz']
     diff = Diff(a, b)
     self.assertEquals({1: 'baz'}, diff.update)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 30
0
 def test_diff_dict_append(self):
     a = {'roses': 'red'}
     b = {'roses': 'red', 'violets': 'blue'}
     diff = Diff(a, b)
     self.assertEquals({'violets': 'blue'}, diff.append)
     self.assertEquals(b, diff.apply(a))
Ejemplo n.º 31
0
 def test_diff_dict_update(self):
     a = {'roses': 'red', 'violets': 'blue'}
     b = {'roses': 'red', 'violets': 'aqua'}
     diff = Diff(a, b)
     self.assertEquals({'violets': 'aqua'}, diff.update)
     self.assertEquals(b, diff.apply(a))