~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport_implementations.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-12-10 12:06:11 UTC
  • mfrom: (3097.2.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20071210120611-a3j02d26cbzvlyju
Fix 173010 by reading data as it arrives on the http socket (vila)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
TransportTestProviderAdapter.
21
21
"""
22
22
 
 
23
import itertools
23
24
import os
24
25
from cStringIO import StringIO
25
26
from StringIO import StringIO as pyStringIO
186
187
        self.build_tree(files, transport=t, line_endings='binary')
187
188
        self.check_transport_contents('contents of a\n', t, 'a')
188
189
        content_f = t.get_multi(files)
189
 
        for content, f in zip(contents, content_f):
 
190
        # Use itertools.izip() instead of use zip() or map(), since they fully
 
191
        # evaluate their inputs, the transport requests should be issued and
 
192
        # handled sequentially (we don't want to force transport to buffer).
 
193
        for content, f in itertools.izip(contents, content_f):
190
194
            self.assertEqual(content, f.read())
191
195
 
192
196
        content_f = t.get_multi(iter(files))
193
 
        for content, f in zip(contents, content_f):
 
197
        # Use itertools.izip() for the same reason
 
198
        for content, f in itertools.izip(contents, content_f):
194
199
            self.assertEqual(content, f.read())
195
200
 
196
201
        self.assertRaises(NoSuchFile, t.get, 'c')
978
983
        self.check_transport_contents('c this file\n', t, 'b')
979
984
 
980
985
        # TODO: Try to write a test for atomicity
981
 
        # TODO: Test moving into a non-existant subdirectory
 
986
        # TODO: Test moving into a non-existent subdirectory
982
987
        # TODO: Test Transport.move_multi
983
988
 
984
989
    def test_copy(self):
1281
1286
        self.assertEqual('', t.relpath(t.base))
1282
1287
        # base ends with /
1283
1288
        self.assertEqual('', t.relpath(t.base[:-1]))
1284
 
        # subdirs which dont exist should still give relpaths.
 
1289
        # subdirs which don't exist should still give relpaths.
1285
1290
        self.assertEqual('foo', t.relpath(t.base + 'foo'))
1286
1291
        # trailing slash should be the same.
1287
1292
        self.assertEqual('foo', t.relpath(t.base + 'foo/'))
1569
1574
                adjust_for_latency=True, upper_limit=content_size))
1570
1575
            self.assertEqual(1, len(result))
1571
1576
            data_len = len(result[0][1])
1572
 
            # minimmum length is from 400 to 1034 - 634
 
1577
            # minimum length is from 400 to 1034 - 634
1573
1578
            self.assertTrue(data_len >= 634)
1574
1579
            # must contain the region 400 to 1034
1575
1580
            self.assertTrue(result[0][0] <= 400)