Merge lp:~nataliabidart/ubuntuone-storage-protocol/test-failing-stable-3-0 into lp:ubuntuone-storage-protocol/stable-3-0

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 144
Merged at revision: 143
Proposed branch: lp:~nataliabidart/ubuntuone-storage-protocol/test-failing-stable-3-0
Merge into: lp:ubuntuone-storage-protocol/stable-3-0
Diff against target: 272 lines (+34/-49)
5 files modified
tests/test_bytesproducer.py (+3/-1)
tests/test_client.py (+12/-27)
tests/test_request.py (+7/-10)
tests/test_sharersp.py (+4/-1)
tests/test_throttling.py (+8/-10)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-storage-protocol/test-failing-stable-3-0
Reviewer Review Type Date Requested Status
dobey (community) Approve
Manuel de la Peña (community) Approve
Review via email: mp+82192@code.launchpad.net

Commit message

- Fixed tests calls to super() (LP: #890277).

To post a comment you must log in.
Revision history for this message
Manuel de la Peña (mandel) wrote :

Looks good.

review: Approve
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test_bytesproducer.py'
2--- tests/test_bytesproducer.py 2011-04-20 18:49:55 +0000
3+++ tests/test_bytesproducer.py 2011-11-14 16:43:46 +0000
4@@ -23,7 +23,7 @@
5 from unittest import TestCase
6 from cStringIO import StringIO
7
8-from twisted.internet import task
9+from twisted.internet import defer, task
10 from twisted.trial.unittest import TestCase as TwistedTestCase
11
12 from ubuntuone.storageprotocol import client, protocol_pb2
13@@ -94,7 +94,9 @@
14
15 timeout = 1
16
17+ @defer.inlineCallbacks
18 def setUp(self):
19+ yield super(TestGenerateData, self).setUp()
20 fh = StringIO()
21 fh.write("abcde")
22 fh.seek(0)
23
24=== modified file 'tests/test_client.py'
25--- tests/test_client.py 2011-10-06 21:22:58 +0000
26+++ tests/test_client.py 2011-11-14 16:43:46 +0000
27@@ -470,8 +470,9 @@
28
29 request_class = request.Request
30
31+ @defer.inlineCallbacks
32 def setUp(self):
33- """Initialize testing protocol."""
34+ yield super(RequestTestCase, self).setUp()
35 import types
36 self.request_class = types.ClassType(self.request_class.__name__,
37 (self.request_class,), {})
38@@ -482,21 +483,16 @@
39
40 request_class = CreateUDF
41
42+ @defer.inlineCallbacks
43 def setUp(self):
44 """Initialize testing protocol."""
45- super(CreateUDFTestCase, self).setUp()
46+ yield super(CreateUDFTestCase, self).setUp()
47 self.protocol = FakedProtocol()
48 self.request = self.request_class(self.protocol, path=PATH, name=NAME)
49 self.request.error = faked_error
50 self.done_called = False
51 self.request.done = was_called(self, 'done_called')
52
53- def tearDown(self):
54- """Clean up."""
55- self.protocol = None
56- self.request = None
57- super(CreateUDFTestCase, self).tearDown()
58-
59 def test_init(self):
60 """Test request creation."""
61 self.assertEquals(PATH, self.request.path)
62@@ -538,20 +534,16 @@
63
64 request_class = ListVolumes
65
66+ @defer.inlineCallbacks
67 def setUp(self):
68 """Initialize testing protocol."""
69- super(ListVolumesTestCase, self).setUp()
70+ yield super(ListVolumesTestCase, self).setUp()
71 self.protocol = FakedProtocol()
72 self.request = self.request_class(self.protocol)
73 self.request.error = faked_error
74 self.done_called = False
75 self.request.done = was_called(self, 'done_called')
76
77- def tearDown(self):
78- """Clean up."""
79- self.protocol = None
80- self.request = None
81-
82 def test_init(self):
83 """Test request creation."""
84 self.assertEquals([], self.request.volumes)
85@@ -624,20 +616,16 @@
86
87 request_class = DeleteVolume
88
89+ @defer.inlineCallbacks
90 def setUp(self):
91 """Initialize testing protocol."""
92- super(DeleteVolumeTestCase, self).setUp()
93+ yield super(DeleteVolumeTestCase, self).setUp()
94 self.protocol = FakedProtocol()
95 self.request = self.request_class(self.protocol, volume_id=VOLUME)
96 self.request.error = faked_error
97 self.done_called = False
98 self.request.done = was_called(self, 'done_called')
99
100- def tearDown(self):
101- """Clean up."""
102- self.protocol = None
103- self.request = None
104-
105 def test_init(self):
106 """Test request creation."""
107 self.assertEquals(str(VOLUME), self.request.volume_id)
108@@ -671,20 +659,16 @@
109
110 request_class = GetDelta
111
112+ @defer.inlineCallbacks
113 def setUp(self):
114 """Initialize testing protocol."""
115- super(GetDeltaTestCase, self).setUp()
116+ yield super(GetDeltaTestCase, self).setUp()
117 self.protocol = FakedProtocol()
118 self.request = self.request_class(self.protocol, SHARE, 0)
119 self.request.error = faked_error
120 self.done_called = False
121 self.request.done = was_called(self, 'done_called')
122
123- def tearDown(self):
124- """Clean up."""
125- self.protocol = None
126- self.request = None
127-
128 def test_init(self):
129 """Test request creation."""
130 self.assertEquals(str(SHARE), self.request.share_id)
131@@ -872,8 +856,9 @@
132 class TimestampCheckerTestCase(TwistedTestCase):
133 """Tests for the timestamp checker."""
134
135+ @defer.inlineCallbacks
136 def setUp(self):
137- """Initialize a fake webserver."""
138+ yield super(TimestampCheckerTestCase, self).setUp()
139 self.ws = MockWebServer()
140 self.addCleanup(self.ws.stop)
141 self.patch(TwistedTimestampChecker, "SERVER_URL", self.ws.get_url())
142
143=== modified file 'tests/test_request.py'
144--- tests/test_request.py 2010-11-04 14:18:06 +0000
145+++ tests/test_request.py 2011-11-14 16:43:46 +0000
146@@ -23,9 +23,9 @@
147
148 import uuid
149
150+from twisted.internet import defer
151+from twisted.python.failure import Failure
152 from twisted.trial.unittest import TestCase as TwistedTestCase
153-from twisted.internet.defer import inlineCallbacks
154-from twisted.python.failure import Failure
155
156 from ubuntuone.storageprotocol import errors, protocol_pb2
157 from ubuntuone.storageprotocol.request import (
158@@ -72,20 +72,16 @@
159
160 timeout = 2
161
162+ @defer.inlineCallbacks
163 def setUp(self):
164- """Init."""
165+ yield super(TestRequest, self).setUp()
166 transport = ConnectionLike()
167 protocol = RequestHandler()
168 protocol.makeConnection(transport)
169 self.request = MindlessRequest(protocol=protocol)
170 self.error = None
171
172- def tearDown(self):
173- """Clean up."""
174- self.error = None
175- self.request = None
176-
177- @inlineCallbacks
178+ @defer.inlineCallbacks
179 def test_disconnect_aborts_requests(self):
180 """Test that disconnection aborts outstanding requests."""
181
182@@ -176,8 +172,9 @@
183 class TestRequestResponse(TestRequest):
184 """Tests for RequestResponse."""
185
186+ @defer.inlineCallbacks
187 def setUp(self):
188- """Init."""
189+ yield super(TestRequestResponse, self).setUp()
190 message = protocol_pb2.Message()
191 message.id = 1
192 transport = ConnectionLike()
193
194=== modified file 'tests/test_sharersp.py'
195--- tests/test_sharersp.py 2010-09-16 14:59:29 +0000
196+++ tests/test_sharersp.py 2011-11-14 16:43:46 +0000
197@@ -19,7 +19,9 @@
198
199 import uuid
200
201+from twisted.internet import defer
202 from twisted.trial.unittest import TestCase
203+
204 from ubuntuone.storageprotocol.sharersp import ShareResponse
205 from ubuntuone.storageprotocol import protocol_pb2
206
207@@ -88,8 +90,9 @@
208
209 access_level = 'View'
210
211+ @defer.inlineCallbacks
212 def setUp(self):
213- """Setup."""
214+ yield super(ShareResponseFromToMsgTest, self).setUp()
215 self.msg = protocol_pb2.Message()
216 self.msg.type = protocol_pb2.Message.SHARES_INFO
217
218
219=== modified file 'tests/test_throttling.py'
220--- tests/test_throttling.py 2010-11-04 14:18:06 +0000
221+++ tests/test_throttling.py 2011-11-14 16:43:46 +0000
222@@ -20,7 +20,7 @@
223
224 from __future__ import with_statement
225
226-from twisted.internet import task
227+from twisted.internet import defer, task
228 from twisted.trial.unittest import TestCase as TwistedTestCase
229
230 from ubuntuone.storageprotocol import client
231@@ -52,18 +52,14 @@
232 class BaseThrottlingTestCase(TwistedTestCase):
233 """Base test case for ThrottlingStorageClientFactory."""
234
235+ @defer.inlineCallbacks
236 def setUp(self):
237+ yield super(BaseThrottlingTestCase, self).setUp()
238 self.client = FakeClient()
239 self.factories = []
240 self.clock = task.Clock()
241- # use our custom clock instead of the reactor for the callLater
242- self.old_callLater = client.ThrottlingStorageClientFactory.callLater
243- client.ThrottlingStorageClientFactory.callLater = self.clock.callLater
244-
245- def tearDown(self):
246- for f in self.factories:
247- f.unregisterProtocol(None)
248- client.ThrottlingStorageClientFactory.callLater = self.old_callLater
249+ self.patch(client.ThrottlingStorageClientFactory, 'callLater',
250+ self.clock.callLater)
251
252 def create_factory(self, enabled, read_limit, write_limit):
253 """Create a ThrottlingStorageClientFactory with the specified args."""
254@@ -71,6 +67,7 @@
255 write_limit)
256 tscf.client = self.client
257 self.factories.append(tscf)
258+ self.addCleanup(self.destroy_factory, tscf)
259 return tscf
260
261 def destroy_factory(self, factory):
262@@ -82,8 +79,9 @@
263 class TestProducingState(BaseThrottlingTestCase):
264 """Tests for 'producing' state with different limit values."""
265
266+ @defer.inlineCallbacks
267 def setUp(self):
268- BaseThrottlingTestCase.setUp(self)
269+ yield super(TestProducingState, self).setUp()
270 self.tscf = self.create_factory(True, 3, 3)
271
272 def test_under_write_limit(self):

Subscribers

People subscribed via source and target branches