Merge lp:~facundo/ubuntuone-client/aq-slots into lp:ubuntuone-client

Proposed by Facundo Batista on 2011-04-07
Status: Merged
Approved by: Facundo Batista on 2011-04-08
Approved revision: 947
Merged at revision: 948
Proposed branch: lp:~facundo/ubuntuone-client/aq-slots
Merge into: lp:ubuntuone-client
Diff against target: 50 lines (+15/-0)
2 files modified
tests/syncdaemon/test_action_queue.py (+11/-0)
ubuntuone/syncdaemon/action_queue.py (+4/-0)
To merge this branch: bzr merge lp:~facundo/ubuntuone-client/aq-slots
Reviewer Review Type Date Requested Status
Facundo Batista Approve on 2011-04-08
dobey (community) 2011-04-07 Approve on 2011-04-08
Review via email: mp+56846@code.launchpad.net

Commit message

Assure all commands declare __slots__ (LP: #721483).

Description of the change

Assure all commands declare __slots__.

This is because even if you subclass a class that declares it, you will not inherit its particular behaviour.

Test included.

To post a comment you must log in.
dobey (dobey) :
review: Approve
Facundo Batista (facundo) wrote :

Approving with one review

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/syncdaemon/test_action_queue.py'
2--- tests/syncdaemon/test_action_queue.py 2011-04-06 13:41:36 +0000
3+++ tests/syncdaemon/test_action_queue.py 2011-04-07 21:17:29 +0000
4@@ -56,6 +56,7 @@
5 request,
6 )
7 from ubuntuone.syncdaemon import states, interfaces
8+from ubuntuone.syncdaemon import action_queue
9 from ubuntuone.syncdaemon.action_queue import (
10 ActionQueue, ActionQueueCommand, ChangePublicAccess, CreateUDF,
11 DeleteVolume, Download, ListVolumes, ActionQueueProtocol,
12@@ -2081,6 +2082,16 @@
13 self.assertFalse(called)
14 self.assertTrue(self.cmd.cancelled)
15
16+ def test_slots(self):
17+ """Inherited commands must have __slot__ (that is not inherited)."""
18+ for obj_name in dir(action_queue):
19+ obj = getattr(action_queue, obj_name)
20+ if isinstance(obj, type) and issubclass(obj, ActionQueueCommand) \
21+ and obj is not ActionQueueCommand:
22+ self.assertNotIdentical(obj.__slots__,
23+ ActionQueueCommand.__slots__,
24+ "class %s has no __slots__" % obj)
25+
26
27 class CreateUDFTestCase(ConnectedBaseTestCase):
28 """Test for CreateUDF ActionQueueCommand."""
29
30=== modified file 'ubuntuone/syncdaemon/action_queue.py'
31--- ubuntuone/syncdaemon/action_queue.py 2011-04-06 13:41:36 +0000
32+++ ubuntuone/syncdaemon/action_queue.py 2011-04-07 21:17:29 +0000
33@@ -1587,6 +1587,8 @@
34 class FreeSpaceInquiry(ActionQueueCommand):
35 """Inquire about free space."""
36
37+ __slots__ = ()
38+
39 def __init__(self, request_queue, share_id):
40 """Initialize the instance."""
41 super(FreeSpaceInquiry, self).__init__(request_queue)
42@@ -1611,6 +1613,8 @@
43 class AccountInquiry(ActionQueueCommand):
44 """Query user account information."""
45
46+ __slots__ = ()
47+
48 def _run(self):
49 """Make the actual request."""
50 return self.action_queue.client.get_account_info()

Subscribers

People subscribed via source and target branches