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

Proposed by Facundo Batista
Status: Merged
Approved by: Facundo Batista
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 (community) Approve
dobey (community) Approve
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.
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
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
=== modified file 'tests/syncdaemon/test_action_queue.py'
--- tests/syncdaemon/test_action_queue.py 2011-04-06 13:41:36 +0000
+++ tests/syncdaemon/test_action_queue.py 2011-04-07 21:17:29 +0000
@@ -56,6 +56,7 @@
56 request,56 request,
57)57)
58from ubuntuone.syncdaemon import states, interfaces58from ubuntuone.syncdaemon import states, interfaces
59from ubuntuone.syncdaemon import action_queue
59from ubuntuone.syncdaemon.action_queue import (60from ubuntuone.syncdaemon.action_queue import (
60 ActionQueue, ActionQueueCommand, ChangePublicAccess, CreateUDF,61 ActionQueue, ActionQueueCommand, ChangePublicAccess, CreateUDF,
61 DeleteVolume, Download, ListVolumes, ActionQueueProtocol,62 DeleteVolume, Download, ListVolumes, ActionQueueProtocol,
@@ -2081,6 +2082,16 @@
2081 self.assertFalse(called)2082 self.assertFalse(called)
2082 self.assertTrue(self.cmd.cancelled)2083 self.assertTrue(self.cmd.cancelled)
20832084
2085 def test_slots(self):
2086 """Inherited commands must have __slot__ (that is not inherited)."""
2087 for obj_name in dir(action_queue):
2088 obj = getattr(action_queue, obj_name)
2089 if isinstance(obj, type) and issubclass(obj, ActionQueueCommand) \
2090 and obj is not ActionQueueCommand:
2091 self.assertNotIdentical(obj.__slots__,
2092 ActionQueueCommand.__slots__,
2093 "class %s has no __slots__" % obj)
2094
20842095
2085class CreateUDFTestCase(ConnectedBaseTestCase):2096class CreateUDFTestCase(ConnectedBaseTestCase):
2086 """Test for CreateUDF ActionQueueCommand."""2097 """Test for CreateUDF ActionQueueCommand."""
20872098
=== modified file 'ubuntuone/syncdaemon/action_queue.py'
--- ubuntuone/syncdaemon/action_queue.py 2011-04-06 13:41:36 +0000
+++ ubuntuone/syncdaemon/action_queue.py 2011-04-07 21:17:29 +0000
@@ -1587,6 +1587,8 @@
1587class FreeSpaceInquiry(ActionQueueCommand):1587class FreeSpaceInquiry(ActionQueueCommand):
1588 """Inquire about free space."""1588 """Inquire about free space."""
15891589
1590 __slots__ = ()
1591
1590 def __init__(self, request_queue, share_id):1592 def __init__(self, request_queue, share_id):
1591 """Initialize the instance."""1593 """Initialize the instance."""
1592 super(FreeSpaceInquiry, self).__init__(request_queue)1594 super(FreeSpaceInquiry, self).__init__(request_queue)
@@ -1611,6 +1613,8 @@
1611class AccountInquiry(ActionQueueCommand):1613class AccountInquiry(ActionQueueCommand):
1612 """Query user account information."""1614 """Query user account information."""
16131615
1616 __slots__ = ()
1617
1614 def _run(self):1618 def _run(self):
1615 """Make the actual request."""1619 """Make the actual request."""
1616 return self.action_queue.client.get_account_info()1620 return self.action_queue.client.get_account_info()

Subscribers

People subscribed via source and target branches