/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.py

  • Committer: Andrew Bennetts
  • Date: 2009-10-29 00:16:50 UTC
  • mto: This revision was merged to the branch mainline in revision 4778.
  • Revision ID: andrew.bennetts@canonical.com-20091029001650-lessthfgf0wv8iqh
Add some more tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
import bzrlib.smart.bzrdir, bzrlib.smart.bzrdir as smart_dir
44
44
import bzrlib.smart.packrepository
45
45
import bzrlib.smart.repository
 
46
import bzrlib.smart.vfs
46
47
from bzrlib.smart.request import (
47
48
    FailedSmartServerResponse,
48
49
    SmartServerRequest,
174
175
        self.assertEqual('./' + urlutils.escape(e_acute),
175
176
                         request.translate_client_path('foo/' + e_acute))
176
177
 
 
178
    def test_translate_client_path_vfs(self):
 
179
        """VfsRequests receive escaped paths rather than raw UTF-8."""
 
180
        transport = self.get_transport()
 
181
        request = smart.vfs.VfsRequest(transport, 'foo/')
 
182
        e_acute = u'\N{LATIN SMALL LETTER E WITH ACUTE}'.encode('utf-8')
 
183
        escaped = urlutils.escape('foo/' + e_acute)
 
184
        self.assertEqual('./' + urlutils.escape(e_acute),
 
185
                         request.translate_client_path(escaped))
 
186
 
177
187
    def test_transport_from_client_path(self):
178
188
        transport = self.get_transport()
179
189
        request = SmartServerRequest(transport, 'foo/')
1693
1703
        self.assertEqual(SmartServerResponse(('ok',)), response)
1694
1704
 
1695
1705
 
 
1706
class TestSmartServerVfsGet(tests.TestCaseWithMemoryTransport):
 
1707
 
 
1708
    def test_unicode_path(self):
 
1709
        """VFS requests expect unicode paths to be escaped."""
 
1710
        filename = u'foo\N{INTERROBANG}'
 
1711
        filename_escaped = urlutils.escape(filename)
 
1712
        backing = self.get_transport()
 
1713
        request = smart.vfs.GetRequest(backing)
 
1714
        backing.put_bytes_non_atomic(filename_escaped, 'contents')
 
1715
        self.assertEqual(SmartServerResponse(('ok', ), 'contents'),
 
1716
            request.execute(filename_escaped))
 
1717
 
 
1718
 
1696
1719
class TestHandlers(tests.TestCase):
1697
1720
    """Tests for the request.request_handlers object."""
1698
1721