~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_urlutils.py

Optimize Tree._iter_changes with specific file_ids

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 by Canonical Ltd
 
1
# Copyright (C) 2005 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
275
275
 
276
276
        self.assertEqual('file:///D:/path/to/r%C3%A4ksm%C3%B6rg%C3%A5s', result)
277
277
 
 
278
    def test_win32_unc_path_to_url(self):
 
279
        to_url = urlutils._win32_local_path_to_url
 
280
        self.assertEqual('file://HOST/path',
 
281
            to_url(r'\\HOST\path'))
 
282
        self.assertEqual('file://HOST/path',
 
283
            to_url('//HOST/path'))
 
284
 
 
285
        try:
 
286
            result = to_url(u'//HOST/path/to/r\xe4ksm\xf6rg\xe5s')
 
287
        except UnicodeError:
 
288
            raise TestSkipped("local encoding cannot handle unicode")
 
289
 
 
290
        self.assertEqual('file://HOST/path/to/r%C3%A4ksm%C3%B6rg%C3%A5s', result)
 
291
 
 
292
 
278
293
    def test_win32_local_path_from_url(self):
279
294
        from_url = urlutils._win32_local_path_from_url
280
295
        self.assertEqual('C:/path/to/foo',
288
303
        # Not a valid _win32 url, no drive letter
289
304
        self.assertRaises(InvalidURL, from_url, 'file:///path/to/foo')
290
305
 
291
 
    def test__win32_extract_drive_letter(self):
 
306
    def test_win32_unc_path_from_url(self):
 
307
        from_url = urlutils._win32_local_path_from_url
 
308
        self.assertEqual('//HOST/path', from_url('file://HOST/path'))
 
309
        # despite IE allows 2, 4, 5 and 6 slashes in URL to another machine
 
310
        # we want to use only 2 slashes
 
311
        # Firefox understand only 5 slashes in URL, but it's ugly
 
312
        self.assertRaises(InvalidURL, from_url, 'file:////HOST/path')
 
313
        self.assertRaises(InvalidURL, from_url, 'file://///HOST/path')
 
314
        self.assertRaises(InvalidURL, from_url, 'file://////HOST/path')
 
315
        # check for file://C:/ instead of file:///C:/
 
316
        self.assertRaises(InvalidURL, from_url, 'file://C:/path')
 
317
 
 
318
    def test_win32_extract_drive_letter(self):
292
319
        extract = urlutils._win32_extract_drive_letter
293
320
        self.assertEqual(('file:///C:', '/foo'), extract('file://', '/C:/foo'))
294
321
        self.assertEqual(('file:///d|', '/path'), extract('file://', '/d|/path'))
329
356
        self.assertEqual(('path/..', 'foo'), split('path/../foo'))
330
357
        self.assertEqual(('../path', 'foo'), split('../path/foo'))
331
358
 
332
 
    def test__win32_strip_local_trailing_slash(self):
 
359
    def test_win32_strip_local_trailing_slash(self):
333
360
        strip = urlutils._win32_strip_local_trailing_slash
334
361
        self.assertEqual('file://', strip('file://'))
335
362
        self.assertEqual('file:///', strip('file:///'))