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
=== modified file 'tests/test_bytesproducer.py'
--- tests/test_bytesproducer.py 2011-04-20 18:49:55 +0000
+++ tests/test_bytesproducer.py 2011-11-14 16:25:27 +0000
@@ -23,7 +23,7 @@
23from unittest import TestCase23from unittest import TestCase
24from cStringIO import StringIO24from cStringIO import StringIO
2525
26from twisted.internet import task26from twisted.internet import defer, task
27from twisted.trial.unittest import TestCase as TwistedTestCase27from twisted.trial.unittest import TestCase as TwistedTestCase
2828
29from ubuntuone.storageprotocol import client, protocol_pb229from ubuntuone.storageprotocol import client, protocol_pb2
@@ -94,7 +94,9 @@
9494
95 timeout = 195 timeout = 1
9696
97 @defer.inlineCallbacks
97 def setUp(self):98 def setUp(self):
99 yield super(TestGenerateData, self).setUp()
98 fh = StringIO()100 fh = StringIO()
99 fh.write("abcde")101 fh.write("abcde")
100 fh.seek(0)102 fh.seek(0)
101103
=== modified file 'tests/test_client.py'
--- tests/test_client.py 2011-10-06 21:22:58 +0000
+++ tests/test_client.py 2011-11-14 16:25:27 +0000
@@ -175,10 +175,6 @@
175 self.called = False175 self.called = False
176 self.volume = None176 self.volume = None
177177
178 def tearDown(self):
179 """Clean up."""
180 self.client = None
181
182 def test_init_maxpayloadsize(self):178 def test_init_maxpayloadsize(self):
183 """Get the value from the constant at init time."""179 """Get the value from the constant at init time."""
184 self.assertEqual(self.client.max_payload_size,180 self.assertEqual(self.client.max_payload_size,
@@ -470,8 +466,9 @@
470466
471 request_class = request.Request467 request_class = request.Request
472468
469 @defer.inlineCallbacks
473 def setUp(self):470 def setUp(self):
474 """Initialize testing protocol."""471 yield super(RequestTestCase, self).setUp()
475 import types472 import types
476 self.request_class = types.ClassType(self.request_class.__name__,473 self.request_class = types.ClassType(self.request_class.__name__,
477 (self.request_class,), {})474 (self.request_class,), {})
@@ -482,21 +479,16 @@
482479
483 request_class = CreateUDF480 request_class = CreateUDF
484481
482 @defer.inlineCallbacks
485 def setUp(self):483 def setUp(self):
486 """Initialize testing protocol."""484 """Initialize testing protocol."""
487 super(CreateUDFTestCase, self).setUp()485 yield super(CreateUDFTestCase, self).setUp()
488 self.protocol = FakedProtocol()486 self.protocol = FakedProtocol()
489 self.request = self.request_class(self.protocol, path=PATH, name=NAME)487 self.request = self.request_class(self.protocol, path=PATH, name=NAME)
490 self.request.error = faked_error488 self.request.error = faked_error
491 self.done_called = False489 self.done_called = False
492 self.request.done = was_called(self, 'done_called')490 self.request.done = was_called(self, 'done_called')
493491
494 def tearDown(self):
495 """Clean up."""
496 self.protocol = None
497 self.request = None
498 super(CreateUDFTestCase, self).tearDown()
499
500 def test_init(self):492 def test_init(self):
501 """Test request creation."""493 """Test request creation."""
502 self.assertEquals(PATH, self.request.path)494 self.assertEquals(PATH, self.request.path)
@@ -538,20 +530,16 @@
538530
539 request_class = ListVolumes531 request_class = ListVolumes
540532
533 @defer.inlineCallbacks
541 def setUp(self):534 def setUp(self):
542 """Initialize testing protocol."""535 """Initialize testing protocol."""
543 super(ListVolumesTestCase, self).setUp()536 yield super(ListVolumesTestCase, self).setUp()
544 self.protocol = FakedProtocol()537 self.protocol = FakedProtocol()
545 self.request = self.request_class(self.protocol)538 self.request = self.request_class(self.protocol)
546 self.request.error = faked_error539 self.request.error = faked_error
547 self.done_called = False540 self.done_called = False
548 self.request.done = was_called(self, 'done_called')541 self.request.done = was_called(self, 'done_called')
549542
550 def tearDown(self):
551 """Clean up."""
552 self.protocol = None
553 self.request = None
554
555 def test_init(self):543 def test_init(self):
556 """Test request creation."""544 """Test request creation."""
557 self.assertEquals([], self.request.volumes)545 self.assertEquals([], self.request.volumes)
@@ -624,20 +612,16 @@
624612
625 request_class = DeleteVolume613 request_class = DeleteVolume
626614
615 @defer.inlineCallbacks
627 def setUp(self):616 def setUp(self):
628 """Initialize testing protocol."""617 """Initialize testing protocol."""
629 super(DeleteVolumeTestCase, self).setUp()618 yield super(DeleteVolumeTestCase, self).setUp()
630 self.protocol = FakedProtocol()619 self.protocol = FakedProtocol()
631 self.request = self.request_class(self.protocol, volume_id=VOLUME)620 self.request = self.request_class(self.protocol, volume_id=VOLUME)
632 self.request.error = faked_error621 self.request.error = faked_error
633 self.done_called = False622 self.done_called = False
634 self.request.done = was_called(self, 'done_called')623 self.request.done = was_called(self, 'done_called')
635624
636 def tearDown(self):
637 """Clean up."""
638 self.protocol = None
639 self.request = None
640
641 def test_init(self):625 def test_init(self):
642 """Test request creation."""626 """Test request creation."""
643 self.assertEquals(str(VOLUME), self.request.volume_id)627 self.assertEquals(str(VOLUME), self.request.volume_id)
@@ -671,20 +655,16 @@
671655
672 request_class = GetDelta656 request_class = GetDelta
673657
658 @defer.inlineCallbacks
674 def setUp(self):659 def setUp(self):
675 """Initialize testing protocol."""660 """Initialize testing protocol."""
676 super(GetDeltaTestCase, self).setUp()661 yield super(GetDeltaTestCase, self).setUp()
677 self.protocol = FakedProtocol()662 self.protocol = FakedProtocol()
678 self.request = self.request_class(self.protocol, SHARE, 0)663 self.request = self.request_class(self.protocol, SHARE, 0)
679 self.request.error = faked_error664 self.request.error = faked_error
680 self.done_called = False665 self.done_called = False
681 self.request.done = was_called(self, 'done_called')666 self.request.done = was_called(self, 'done_called')
682667
683 def tearDown(self):
684 """Clean up."""
685 self.protocol = None
686 self.request = None
687
688 def test_init(self):668 def test_init(self):
689 """Test request creation."""669 """Test request creation."""
690 self.assertEquals(str(SHARE), self.request.share_id)670 self.assertEquals(str(SHARE), self.request.share_id)
@@ -872,8 +852,9 @@
872class TimestampCheckerTestCase(TwistedTestCase):852class TimestampCheckerTestCase(TwistedTestCase):
873 """Tests for the timestamp checker."""853 """Tests for the timestamp checker."""
874854
855 @defer.inlineCallbacks
875 def setUp(self):856 def setUp(self):
876 """Initialize a fake webserver."""857 yield super(TimestampCheckerTestCase, self).setUp()
877 self.ws = MockWebServer()858 self.ws = MockWebServer()
878 self.addCleanup(self.ws.stop)859 self.addCleanup(self.ws.stop)
879 self.patch(TwistedTimestampChecker, "SERVER_URL", self.ws.get_url())860 self.patch(TwistedTimestampChecker, "SERVER_URL", self.ws.get_url())
880861
=== modified file 'tests/test_request.py'
--- tests/test_request.py 2010-11-04 14:18:06 +0000
+++ tests/test_request.py 2011-11-14 16:25:27 +0000
@@ -23,9 +23,9 @@
2323
24import uuid24import uuid
2525
26from twisted.internet import defer
27from twisted.python.failure import Failure
26from twisted.trial.unittest import TestCase as TwistedTestCase28from twisted.trial.unittest import TestCase as TwistedTestCase
27from twisted.internet.defer import inlineCallbacks
28from twisted.python.failure import Failure
2929
30from ubuntuone.storageprotocol import errors, protocol_pb230from ubuntuone.storageprotocol import errors, protocol_pb2
31from ubuntuone.storageprotocol.request import (31from ubuntuone.storageprotocol.request import (
@@ -72,20 +72,16 @@
7272
73 timeout = 273 timeout = 2
7474
75 @defer.inlineCallbacks
75 def setUp(self):76 def setUp(self):
76 """Init."""77 yield super(TestRequest, self).setUp()
77 transport = ConnectionLike()78 transport = ConnectionLike()
78 protocol = RequestHandler()79 protocol = RequestHandler()
79 protocol.makeConnection(transport)80 protocol.makeConnection(transport)
80 self.request = MindlessRequest(protocol=protocol)81 self.request = MindlessRequest(protocol=protocol)
81 self.error = None82 self.error = None
8283
83 def tearDown(self):84 @defer.inlineCallbacks
84 """Clean up."""
85 self.error = None
86 self.request = None
87
88 @inlineCallbacks
89 def test_disconnect_aborts_requests(self):85 def test_disconnect_aborts_requests(self):
90 """Test that disconnection aborts outstanding requests."""86 """Test that disconnection aborts outstanding requests."""
9187
@@ -176,8 +172,9 @@
176class TestRequestResponse(TestRequest):172class TestRequestResponse(TestRequest):
177 """Tests for RequestResponse."""173 """Tests for RequestResponse."""
178174
175 @defer.inlineCallbacks
179 def setUp(self):176 def setUp(self):
180 """Init."""177 yield super(TestRequestResponse, self).setUp()
181 message = protocol_pb2.Message()178 message = protocol_pb2.Message()
182 message.id = 1179 message.id = 1
183 transport = ConnectionLike()180 transport = ConnectionLike()
184181
=== modified file 'tests/test_sharersp.py'
--- tests/test_sharersp.py 2010-09-16 14:59:29 +0000
+++ tests/test_sharersp.py 2011-11-14 16:25:27 +0000
@@ -19,7 +19,9 @@
1919
20import uuid20import uuid
2121
22from twisted.internet import defer
22from twisted.trial.unittest import TestCase23from twisted.trial.unittest import TestCase
24
23from ubuntuone.storageprotocol.sharersp import ShareResponse25from ubuntuone.storageprotocol.sharersp import ShareResponse
24from ubuntuone.storageprotocol import protocol_pb226from ubuntuone.storageprotocol import protocol_pb2
2527
@@ -88,8 +90,9 @@
8890
89 access_level = 'View'91 access_level = 'View'
9092
93 @defer.inlineCallbacks
91 def setUp(self):94 def setUp(self):
92 """Setup."""95 yield super(ShareResponseFromToMsgTest, self).setUp()
93 self.msg = protocol_pb2.Message()96 self.msg = protocol_pb2.Message()
94 self.msg.type = protocol_pb2.Message.SHARES_INFO97 self.msg.type = protocol_pb2.Message.SHARES_INFO
9598
9699
=== modified file 'tests/test_throttling.py'
--- tests/test_throttling.py 2010-11-04 14:18:06 +0000
+++ tests/test_throttling.py 2011-11-14 16:25:27 +0000
@@ -20,7 +20,7 @@
2020
21from __future__ import with_statement21from __future__ import with_statement
2222
23from twisted.internet import task23from twisted.internet import defer, task
24from twisted.trial.unittest import TestCase as TwistedTestCase24from twisted.trial.unittest import TestCase as TwistedTestCase
2525
26from ubuntuone.storageprotocol import client26from ubuntuone.storageprotocol import client
@@ -52,18 +52,14 @@
52class BaseThrottlingTestCase(TwistedTestCase):52class BaseThrottlingTestCase(TwistedTestCase):
53 """Base test case for ThrottlingStorageClientFactory."""53 """Base test case for ThrottlingStorageClientFactory."""
5454
55 @defer.inlineCallbacks
55 def setUp(self):56 def setUp(self):
57 yield super(BaseThrottlingTestCase, self).setUp()
56 self.client = FakeClient()58 self.client = FakeClient()
57 self.factories = []59 self.factories = []
58 self.clock = task.Clock()60 self.clock = task.Clock()
59 # use our custom clock instead of the reactor for the callLater61 self.patch(client.ThrottlingStorageClientFactory, 'callLater',
60 self.old_callLater = client.ThrottlingStorageClientFactory.callLater62 self.clock.callLater)
61 client.ThrottlingStorageClientFactory.callLater = self.clock.callLater
62
63 def tearDown(self):
64 for f in self.factories:
65 f.unregisterProtocol(None)
66 client.ThrottlingStorageClientFactory.callLater = self.old_callLater
6763
68 def create_factory(self, enabled, read_limit, write_limit):64 def create_factory(self, enabled, read_limit, write_limit):
69 """Create a ThrottlingStorageClientFactory with the specified args."""65 """Create a ThrottlingStorageClientFactory with the specified args."""
@@ -71,6 +67,7 @@
71 write_limit)67 write_limit)
72 tscf.client = self.client68 tscf.client = self.client
73 self.factories.append(tscf)69 self.factories.append(tscf)
70 self.addCleanup(self.destroy_factory, tscf)
74 return tscf71 return tscf
7572
76 def destroy_factory(self, factory):73 def destroy_factory(self, factory):
@@ -82,8 +79,9 @@
82class TestProducingState(BaseThrottlingTestCase):79class TestProducingState(BaseThrottlingTestCase):
83 """Tests for 'producing' state with different limit values."""80 """Tests for 'producing' state with different limit values."""
8481
82 @defer.inlineCallbacks
85 def setUp(self):83 def setUp(self):
86 BaseThrottlingTestCase.setUp(self)84 yield super(TestProducingState, self).setUp()
87 self.tscf = self.create_factory(True, 3, 3)85 self.tscf = self.create_factory(True, 3, 3)
8886
89 def test_under_write_limit(self):87 def test_under_write_limit(self):

Subscribers

People subscribed via source and target branches