4
4
from bzrlib.tests import TestCaseInTempDir, TestCase
5
5
from bzrlib.branch import Branch
6
from bzrlib.errors import NotBranchError
6
from bzrlib.errors import NotBranchError, NoSuchFile
7
7
from bzrlib.inventory import InventoryFile, Inventory
8
8
from bzrlib.workingtree import WorkingTree
9
from bzrlib.add import smart_add
10
11
class TestSmartAdd(TestCaseInTempDir):
85
86
self.capture('add --dry-run .')
86
87
eq(list(t.unknowns()), ['inertiatic'])
89
def test_add_non_existant(self):
90
"""Test smart-adding a file that does not exist."""
91
from bzrlib.add import smart_add
92
branch = Branch.initialize(u".")
93
self.assertRaises(NoSuchFile, smart_add, 'non-existant-file')
95
def test_returns(self):
96
"""Correctly returns added/ignored files"""
97
from bzrlib.commands import run_bzr
98
b = Branch.initialize(u'.')
100
self.build_tree(['inertiatic/', 'inertiatic/esp', 'inertiatic/CVS',
101
'inertiatic/foo.pyc'])
102
added, ignored = smart_add(u'.')
103
self.AssertSubset(('inertiatic', 'inertiatic/esp'), added)
104
self.AssertSubset(('CVS', '*.py[oc]'), ignored)
105
self.AssertSubset(('inertiatic/CVS',), ignored['CVS'])
106
self.AssertSubset(('inertiatic/foo.pyc',), ignored['*.py[oc]'])
88
109
class TestSmartAddBranch(TestCaseInTempDir):
89
110
"""Test smart adds with a specified branch."""