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