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

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

Subscribers

People subscribed via source and target branches