~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_add.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-12 14:24:06 UTC
  • mfrom: (1858 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1860.
  • Revision ID: john@arbash-meinel.com-20060712142406-d61dbe10e698517d
[merge] bzr.dev 1858

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import os
2
2
import unittest
3
3
 
 
4
from bzrlib import errors, osutils
4
5
from bzrlib.add import smart_add, smart_add_tree
5
 
from bzrlib.tests import TestCaseWithTransport, TestCase
 
6
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
6
7
from bzrlib.errors import NoSuchFile
7
8
from bzrlib.inventory import InventoryFile, Inventory
8
9
from bzrlib.workingtree import WorkingTree
212
213
                    'Accidentally added path: %s' % (path,))
213
214
 
214
215
 
 
216
class TestAddNonNormalized(TestCaseWithTransport):
 
217
 
 
218
    def make(self):
 
219
        try:
 
220
            self.build_tree([u'a\u030a'])
 
221
        except UnicodeError:
 
222
            raise TestSkipped('Filesystem cannot create unicode filenames')
 
223
 
 
224
        self.wt = self.make_branch_and_tree('.')
 
225
 
 
226
    def test_accessible_explicit(self):
 
227
        self.make()
 
228
        orig = osutils.normalized_filename
 
229
        osutils.normalized_filename = osutils._accessible_normalized_filename
 
230
        try:
 
231
            smart_add_tree(self.wt, [u'a\u030a'])
 
232
            self.assertEqual([(u'\xe5', 'file')],
 
233
                    [(path, ie.kind) for path,ie in 
 
234
                        self.wt.inventory.iter_entries()])
 
235
        finally:
 
236
            osutils.normalized_filename = orig
 
237
 
 
238
    def test_accessible_implicit(self):
 
239
        self.make()
 
240
        orig = osutils.normalized_filename
 
241
        osutils.normalized_filename = osutils._accessible_normalized_filename
 
242
        try:
 
243
            smart_add_tree(self.wt, [])
 
244
            self.assertEqual([(u'\xe5', 'file')],
 
245
                    [(path, ie.kind) for path,ie in 
 
246
                        self.wt.inventory.iter_entries()])
 
247
        finally:
 
248
            osutils.normalized_filename = orig
 
249
 
 
250
    def test_inaccessible_explicit(self):
 
251
        self.make()
 
252
        orig = osutils.normalized_filename
 
253
        osutils.normalized_filename = osutils._inaccessible_normalized_filename
 
254
        try:
 
255
            self.assertRaises(errors.InvalidNormalization,
 
256
                    smart_add_tree, self.wt, [u'a\u030a'])
 
257
        finally:
 
258
            osutils.normalized_filename = orig
 
259
 
 
260
    def test_inaccessible_implicit(self):
 
261
        self.make()
 
262
        orig = osutils.normalized_filename
 
263
        osutils.normalized_filename = osutils._inaccessible_normalized_filename
 
264
        try:
 
265
            # TODO: jam 20060701 In the future, this should probably
 
266
            #       just ignore files that don't fit the normalization
 
267
            #       rules, rather than exploding
 
268
            self.assertRaises(errors.InvalidNormalization,
 
269
                    smart_add_tree, self.wt, [])
 
270
        finally:
 
271
            osutils.normalized_filename = orig
 
272
 
 
273
 
215
274
class TestAddActions(TestCase):
216
275
 
217
276
    def test_quiet(self):