~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.py

Combine adjacent substreams of the same type in bzrlib.smart.repository._byte_stream_to_stream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    smart,
37
37
    tests,
38
38
    urlutils,
 
39
    versionedfile,
39
40
    )
40
41
from bzrlib.branch import Branch, BranchReferenceFormat
41
42
import bzrlib.smart.branch
113
114
        return self.get_transport().get_smart_medium()
114
115
 
115
116
 
 
117
class TestByteStreamToStream(tests.TestCase):
 
118
 
 
119
    def test_repeated_substreams_same_kind_are_one_stream(self):
 
120
        # Make a stream - an iterable of bytestrings.
 
121
        stream = [('text', [versionedfile.FulltextContentFactory(('k1',), None,
 
122
            None, 'foo')]),('text', [
 
123
            versionedfile.FulltextContentFactory(('k2',), None, None, 'bar')])]
 
124
        fmt = bzrdir.format_registry.get('pack-0.92')().repository_format
 
125
        bytes = smart.repository._stream_to_byte_stream(stream, fmt)
 
126
        streams = []
 
127
        # Iterate the resulting iterable; checking that we get only one stream
 
128
        # out.
 
129
        fmt, stream = smart.repository._byte_stream_to_stream(bytes)
 
130
        for kind, substream in stream:
 
131
            streams.append((kind, list(substream)))
 
132
        self.assertLength(1, streams)
 
133
        self.assertLength(2, streams[0][1])
 
134
 
 
135
 
116
136
class TestSmartServerResponse(tests.TestCase):
117
137
 
118
138
    def test__eq__(self):