182
182
class TestAddActions(TestCaseInTempDir):
184
184
def test_null(self):
185
from bzrlib.add import add_action_null
186
self.run_action(add_action_null, "", False)
185
self.run_action("", False)
188
187
def test_add(self):
189
self.entry = InventoryFile("id", "name", None)
190
from bzrlib.add import add_action_add
191
self.run_action(add_action_add, "", True)
188
self.run_action("", True)
193
190
def test_add_and_print(self):
194
from bzrlib.add import add_action_add_and_print
195
self.run_action(add_action_add_and_print, "added path\n", True)
191
self.run_action("added path\n", True)
197
193
def test_print(self):
198
from bzrlib.add import add_action_print
199
self.run_action(add_action_print, "added path\n", False)
194
self.run_action("added path\n", False)
201
def run_action(self, action, output, should_add):
202
from StringIO import StringIO
196
def run_action(self, output, should_add):
197
from bzrlib.add import AddAction
198
from cStringIO import StringIO
203
199
inv = Inventory()
204
200
stdout = StringIO()
201
action = AddAction(to_file=stdout,
202
should_print=bool(output), should_add=should_add)
206
204
self.apply_redirected(None, stdout, None, action, inv, 'path', 'file')
207
205
self.assertEqual(stdout.getvalue(), output)