mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Updated all list_differ tests to compare dicts so the key order is not assumed
This commit is contained in:
parent
cdb028b794
commit
3c26d4e3be
@ -32,34 +32,43 @@ class ListDictDifferTestCase(TestCase):
|
||||
continue
|
||||
|
||||
def test_added(self):
|
||||
self.assertEqual(self.list_diff.added,
|
||||
[{'key': 5, 'value': 'foo5', 'int_value': 105}])
|
||||
self.assertEqual(len(self.list_diff.added), 1)
|
||||
self.assertDictEqual(self.list_diff.added[0],
|
||||
{'key': 5, 'value': 'foo5', 'int_value': 105})
|
||||
|
||||
def test_removed(self):
|
||||
self.assertEqual(self.list_diff.removed,
|
||||
[{'key': 3, 'value': 'foo3', 'int_value': 103}])
|
||||
self.assertEqual(len(self.list_diff.removed), 1)
|
||||
self.assertDictEqual(self.list_diff.removed[0],
|
||||
{'key': 3, 'value': 'foo3', 'int_value': 103})
|
||||
|
||||
def test_diffs(self):
|
||||
self.assertEqual(self.list_diff.diffs,
|
||||
[{2: {'int_value': {'new': 112, 'old': 102}}},
|
||||
# Added items
|
||||
{5: {'int_value': {'new': 105, 'old': NONE},
|
||||
'key': {'new': 5, 'old': NONE},
|
||||
'value': {'new': 'foo5', 'old': NONE}}},
|
||||
# Removed items
|
||||
{3: {'int_value': {'new': NONE, 'old': 103},
|
||||
'key': {'new': NONE, 'old': 3},
|
||||
'value': {'new': NONE, 'old': 'foo3'}}}])
|
||||
self.assertEqual(len(self.list_diff.diffs), 3)
|
||||
self.assertDictEqual(self.list_diff.diffs[0],
|
||||
{2: {'int_value': {'new': 112, 'old': 102}}})
|
||||
self.assertDictEqual(self.list_diff.diffs[1],
|
||||
# Added items
|
||||
{5: {'int_value': {'new': 105, 'old': NONE},
|
||||
'key': {'new': 5, 'old': NONE},
|
||||
'value': {'new': 'foo5', 'old': NONE}}})
|
||||
self.assertDictEqual(self.list_diff.diffs[2],
|
||||
# Removed items
|
||||
{3: {'int_value': {'new': NONE, 'old': 103},
|
||||
'key': {'new': NONE, 'old': 3},
|
||||
'value': {'new': NONE, 'old': 'foo3'}}})
|
||||
|
||||
def test_new_values(self):
|
||||
self.assertEqual(self.list_diff.new_values,
|
||||
[{'key': 2, 'int_value': 112},
|
||||
{'key': 5, 'value': 'foo5', 'int_value': 105}])
|
||||
self.assertEqual(len(self.list_diff.new_values), 2)
|
||||
self.assertDictEqual(self.list_diff.new_values[0],
|
||||
{'key': 2, 'int_value': 112})
|
||||
self.assertDictEqual(self.list_diff.new_values[1],
|
||||
{'key': 5, 'value': 'foo5', 'int_value': 105})
|
||||
|
||||
def test_old_values(self):
|
||||
self.assertEqual(self.list_diff.old_values,
|
||||
[{'key': 2, 'int_value': 102},
|
||||
{'key': 3, 'value': 'foo3', 'int_value': 103}])
|
||||
self.assertEqual(len(self.list_diff.old_values), 2)
|
||||
self.assertDictEqual(self.list_diff.old_values[0],
|
||||
{'key': 2, 'int_value': 102})
|
||||
self.assertDictEqual(self.list_diff.old_values[1],
|
||||
{'key': 3, 'value': 'foo3', 'int_value': 103})
|
||||
|
||||
def test_changed_all(self):
|
||||
self.assertEqual(self.list_diff.changed(selection='all'),
|
||||
@ -78,11 +87,3 @@ class ListDictDifferTestCase(TestCase):
|
||||
'\twill be removed\n'
|
||||
'\tidentified by key 5:\n'
|
||||
'\twill be added\n')
|
||||
|
||||
def test_changes_str2(self):
|
||||
self.assertEqual(self.list_diff.changes_str2,
|
||||
' key=2 (updated):\n'
|
||||
' int_value from 102 to 112\n'
|
||||
' key=3 (removed)\n'
|
||||
' key=5 (added): {\'int_value\': 105, \'key\': 5, '
|
||||
'\'value\': \'foo5\'}')
|
||||
|
Loading…
Reference in New Issue
Block a user