1
# Copyright (C) 2004, 2005, 2006, 2007 Canonical Ltd
1
# Copyright (C) 2004, 2005, 2006, 2007, 2009 Canonical Ltd
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
18
18
"""Tests for log+ transport decorator."""
21
24
from bzrlib.tests import TestCaseWithMemoryTransport
22
25
from bzrlib.trace import mutter
23
26
from bzrlib.transport import get_transport
27
from bzrlib.transport.log import TransportLogDecorator
26
30
class TestTransportLog(TestCaseWithMemoryTransport):
41
45
# and they operate on the underlying transport
42
46
self.assertTrue(base_transport.has('subdir'))
48
def test_log_readv(self):
49
# see <https://bugs.launchpad.net/bzr/+bug/340347>
51
# transports are not required to return a generator, but we
52
# specifically want to check that those that do cause it to be passed
53
# through, for the sake of minimum interference
54
base_transport = DummyReadvTransport()
55
# construct it directly to avoid needing the dummy transport to be
57
logging_transport = TransportLogDecorator(
58
'log+dummy:///', _decorated=base_transport)
60
result = base_transport.readv('foo', [(0, 10)])
61
# sadly there's no types.IteratorType, and GeneratorType is too
63
self.assertTrue(getattr(result, 'next'))
65
result = logging_transport.readv('foo', [(0, 10)])
66
self.assertTrue(getattr(result, 'next'))
67
self.assertEquals(list(result),
71
class DummyReadvTransport(object):
75
def readv(self, filename, offset_length_pairs):
76
yield (0, 'abcdefghij')
78
def abspath(self, path):
79
return self.base + path