bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2008-2011, 2016 Canonical Ltd
|
|
3675.1.1
by Martin Pool
Merge and update log+ transport decorator |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
3675.1.1
by Martin Pool
Merge and update log+ transport decorator |
16 |
|
17 |
||
18 |
"""Tests for log+ transport decorator."""
|
|
19 |
||
20 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
21 |
from breezy import transport |
22 |
from breezy.tests import TestCaseWithMemoryTransport |
|
23 |
from breezy.trace import mutter |
|
24 |
from breezy.transport.log import TransportLogDecorator |
|
|
3675.1.1
by Martin Pool
Merge and update log+ transport decorator |
25 |
|
26 |
||
27 |
class TestTransportLog(TestCaseWithMemoryTransport): |
|
28 |
||
29 |
def test_log_transport(self): |
|
30 |
base_transport = self.get_transport('') |
|
|
5273.1.7
by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through |
31 |
logging_transport = transport.get_transport( |
32 |
'log+' + base_transport.base) |
|
|
3675.1.1
by Martin Pool
Merge and update log+ transport decorator |
33 |
|
34 |
# operations such as mkdir are logged
|
|
35 |
mutter('where are you?') |
|
36 |
logging_transport.mkdir('subdir') |
|
|
4794.1.15
by Robert Collins
Review feedback. |
37 |
log = self.get_log() |
|
6631.1.1
by Martin
Fix test failures and issues with run with python -Werror |
38 |
# GZ 2017-05-24: Used to expect abspath logged, logger needs fixing.
|
39 |
self.assertContainsRe(log, r'mkdir subdir') |
|
|
4794.1.8
by Robert Collins
Move the passing of test logs to the result to be via the getDetails API and remove all public use of TestCase._get_log. |
40 |
self.assertContainsRe(log, ' --> None') |
|
3675.1.1
by Martin Pool
Merge and update log+ transport decorator |
41 |
# they have the expected effect
|
42 |
self.assertTrue(logging_transport.has('subdir')) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
43 |
# and they operate on the underlying transport
|
|
3675.1.1
by Martin Pool
Merge and update log+ transport decorator |
44 |
self.assertTrue(base_transport.has('subdir')) |
45 |
||
|
4491.2.3
by Martin Pool
Add test for TransportLogDecorator handling of readv |
46 |
def test_log_readv(self): |
47 |
# see <https://bugs.launchpad.net/bzr/+bug/340347>
|
|
48 |
||
49 |
# transports are not required to return a generator, but we
|
|
50 |
# specifically want to check that those that do cause it to be passed
|
|
51 |
# through, for the sake of minimum interference
|
|
52 |
base_transport = DummyReadvTransport() |
|
53 |
# construct it directly to avoid needing the dummy transport to be
|
|
54 |
# registered etc
|
|
55 |
logging_transport = TransportLogDecorator( |
|
56 |
'log+dummy:///', _decorated=base_transport) |
|
57 |
||
58 |
result = base_transport.readv('foo', [(0, 10)]) |
|
59 |
# sadly there's no types.IteratorType, and GeneratorType is too
|
|
60 |
# specific
|
|
|
6973.7.8
by Jelmer Vernooij
Fix more tests. |
61 |
next(result) |
|
4491.2.3
by Martin Pool
Add test for TransportLogDecorator handling of readv |
62 |
|
63 |
result = logging_transport.readv('foo', [(0, 10)]) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
64 |
self.assertEqual(list(result), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
65 |
[(0, 'abcdefghij')]) |
|
4491.2.3
by Martin Pool
Add test for TransportLogDecorator handling of readv |
66 |
|
67 |
||
68 |
class DummyReadvTransport(object): |
|
69 |
||
70 |
base = 'dummy:///' |
|
71 |
||
72 |
def readv(self, filename, offset_length_pairs): |
|
73 |
yield (0, 'abcdefghij') |
|
74 |
||
75 |
def abspath(self, path): |
|
76 |
return self.base + path |