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

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 143
Merged at revision: 143
Proposed branch: lp:~nataliabidart/ubuntuone-storage-protocol/test-failing
Merge into: lp:ubuntuone-storage-protocol
Diff against target: 283 lines (+34/-53)
5 files modified
tests/test_bytesproducer.py (+3/-1)
tests/test_client.py (+12/-31)
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
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve
Review via email: mp+82178@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

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

Subscribers

People subscribed via source and target branches