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

Proposed by Natalia Bidart on 2011-11-14
Status: Merged
Approved by: Natalia Bidart on 2011-11-14
Approved revision: 135
Merged at revision: 135
Proposed branch: lp:~nataliabidart/ubuntuone-storage-protocol/test-failing-stable-1-6
Merge into: lp:ubuntuone-storage-protocol/stable-1-6
Diff against target: 153 lines (+22/-22)
4 files modified
tests/test_bytesproducer.py (+3/-1)
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-1-6
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) 2011-11-14 Approve on 2011-11-14
Review via email: mp+82190@code.launchpad.net

Commit message

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

To post a comment you must log in.
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-25 21:00:47 +0000
3+++ tests/test_bytesproducer.py 2011-11-14 16:43:41 +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_request.py'
25--- tests/test_request.py 2010-11-04 14:18:06 +0000
26+++ tests/test_request.py 2011-11-14 16:43:41 +0000
27@@ -23,9 +23,9 @@
28
29 import uuid
30
31+from twisted.internet import defer
32+from twisted.python.failure import Failure
33 from twisted.trial.unittest import TestCase as TwistedTestCase
34-from twisted.internet.defer import inlineCallbacks
35-from twisted.python.failure import Failure
36
37 from ubuntuone.storageprotocol import errors, protocol_pb2
38 from ubuntuone.storageprotocol.request import (
39@@ -72,20 +72,16 @@
40
41 timeout = 2
42
43+ @defer.inlineCallbacks
44 def setUp(self):
45- """Init."""
46+ yield super(TestRequest, self).setUp()
47 transport = ConnectionLike()
48 protocol = RequestHandler()
49 protocol.makeConnection(transport)
50 self.request = MindlessRequest(protocol=protocol)
51 self.error = None
52
53- def tearDown(self):
54- """Clean up."""
55- self.error = None
56- self.request = None
57-
58- @inlineCallbacks
59+ @defer.inlineCallbacks
60 def test_disconnect_aborts_requests(self):
61 """Test that disconnection aborts outstanding requests."""
62
63@@ -176,8 +172,9 @@
64 class TestRequestResponse(TestRequest):
65 """Tests for RequestResponse."""
66
67+ @defer.inlineCallbacks
68 def setUp(self):
69- """Init."""
70+ yield super(TestRequestResponse, self).setUp()
71 message = protocol_pb2.Message()
72 message.id = 1
73 transport = ConnectionLike()
74
75=== modified file 'tests/test_sharersp.py'
76--- tests/test_sharersp.py 2010-09-16 14:59:29 +0000
77+++ tests/test_sharersp.py 2011-11-14 16:43:41 +0000
78@@ -19,7 +19,9 @@
79
80 import uuid
81
82+from twisted.internet import defer
83 from twisted.trial.unittest import TestCase
84+
85 from ubuntuone.storageprotocol.sharersp import ShareResponse
86 from ubuntuone.storageprotocol import protocol_pb2
87
88@@ -88,8 +90,9 @@
89
90 access_level = 'View'
91
92+ @defer.inlineCallbacks
93 def setUp(self):
94- """Setup."""
95+ yield super(ShareResponseFromToMsgTest, self).setUp()
96 self.msg = protocol_pb2.Message()
97 self.msg.type = protocol_pb2.Message.SHARES_INFO
98
99
100=== modified file 'tests/test_throttling.py'
101--- tests/test_throttling.py 2010-11-04 14:18:06 +0000
102+++ tests/test_throttling.py 2011-11-14 16:43:41 +0000
103@@ -20,7 +20,7 @@
104
105 from __future__ import with_statement
106
107-from twisted.internet import task
108+from twisted.internet import defer, task
109 from twisted.trial.unittest import TestCase as TwistedTestCase
110
111 from ubuntuone.storageprotocol import client
112@@ -52,18 +52,14 @@
113 class BaseThrottlingTestCase(TwistedTestCase):
114 """Base test case for ThrottlingStorageClientFactory."""
115
116+ @defer.inlineCallbacks
117 def setUp(self):
118+ yield super(BaseThrottlingTestCase, self).setUp()
119 self.client = FakeClient()
120 self.factories = []
121 self.clock = task.Clock()
122- # use our custom clock instead of the reactor for the callLater
123- self.old_callLater = client.ThrottlingStorageClientFactory.callLater
124- client.ThrottlingStorageClientFactory.callLater = self.clock.callLater
125-
126- def tearDown(self):
127- for f in self.factories:
128- f.unregisterProtocol(None)
129- client.ThrottlingStorageClientFactory.callLater = self.old_callLater
130+ self.patch(client.ThrottlingStorageClientFactory, 'callLater',
131+ self.clock.callLater)
132
133 def create_factory(self, enabled, read_limit, write_limit):
134 """Create a ThrottlingStorageClientFactory with the specified args."""
135@@ -71,6 +67,7 @@
136 write_limit)
137 tscf.client = self.client
138 self.factories.append(tscf)
139+ self.addCleanup(self.destroy_factory, tscf)
140 return tscf
141
142 def destroy_factory(self, factory):
143@@ -82,8 +79,9 @@
144 class TestProducingState(BaseThrottlingTestCase):
145 """Tests for 'producing' state with different limit values."""
146
147+ @defer.inlineCallbacks
148 def setUp(self):
149- BaseThrottlingTestCase.setUp(self)
150+ yield super(TestProducingState, self).setUp()
151 self.tscf = self.create_factory(True, 3, 3)
152
153 def test_under_write_limit(self):

Subscribers

People subscribed via source and target branches