72
73
self.assertEqual({'key': ('value', True)}, config)
76
class TestPlanUpdate(unittest.TestCase):
77
"""Tests for how to plan the update."""
79
def test_trivial(self):
80
# In the trivial case, there are no existing branches and no
81
# configured branches, so there are no branches to add, none to
82
# update, and none to remove.
83
new, existing, removed = plan_update([], {})
84
self.assertEqual({}, new)
85
self.assertEqual({}, existing)
86
self.assertEqual(set(), removed)
88
def test_all_new(self):
89
# If there are no existing branches, then the all of the configured
90
# branches are new, none are existing and none have been removed.
91
new, existing, removed = plan_update([], {'a': ('b', False)})
92
self.assertEqual({'a': ('b', False)}, new)
93
self.assertEqual({}, existing)
94
self.assertEqual(set(), removed)
96
def test_all_old(self):
97
# If there configuration is now empty, but there are existing
98
# branches, then that means all the branches have been removed from
99
# the configuration, none are new and none are updated.
100
new, existing, removed = plan_update(['a', 'b', 'c'], {})
101
self.assertEqual({}, new)
102
self.assertEqual({}, existing)
103
self.assertEqual(set(['a', 'b', 'c']), removed)
105
def test_all_same(self):
106
# If the set of existing branches is the same as the set of
107
# non-existing branches, then they all need to be updated.
108
config = {'a': ('b', False), 'c': ('d', True)}
109
new, existing, removed = plan_update(config.keys(), config)
110
self.assertEqual({}, new)
111
self.assertEqual(config, existing)
112
self.assertEqual(set(), removed)
76
116
return unittest.TestLoader().loadTestsFromName(__name__)