Merge lp:~nataliabidart/ubuntuone-client/run-upload-run-stable-2-0 into lp:ubuntuone-client/stable-2-0
- run-upload-run-stable-2-0
- Merge into stable-2-0
Proposed by
Natalia Bidart
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Natalia Bidart | ||||||||
Approved revision: | 1144 | ||||||||
Merged at revision: | 1142 | ||||||||
Proposed branch: | lp:~nataliabidart/ubuntuone-client/run-upload-run-stable-2-0 | ||||||||
Merge into: | lp:ubuntuone-client/stable-2-0 | ||||||||
Diff against target: |
946 lines (+165/-87) 14 files modified
tests/platform/linux/eventlog/test_zglog.py (+3/-2) tests/platform/linux/test_dbus.py (+2/-1) tests/platform/linux/test_messaging.py (+1/-9) tests/platform/linux/test_notification.py (+1/-9) tests/platform/linux/test_unity.py (+3/-0) tests/platform/linux/test_vm.py (+6/-2) tests/platform/test_interaction_interfaces.py (+18/-8) tests/status/test_aggregator.py (+20/-2) tests/syncdaemon/test_action_queue.py (+58/-13) tests/syncdaemon/test_logger.py (+11/-0) tests/syncdaemon/test_pathlockingtree.py (+8/-0) tests/syncdaemon/test_states.py (+16/-5) tests/syncdaemon/test_status_listener.py (+2/-1) ubuntuone/syncdaemon/action_queue.py (+16/-35) |
||||||||
To merge this branch: | bzr merge lp:~nataliabidart/ubuntuone-client/run-upload-run-stable-2-0 | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Facundo Batista (community) | Approve | ||
Joshua Hoover (community) | tested | Approve | |
Review via email: mp+81475@code.launchpad.net |
Description of the change
To post a comment you must log in.
- 1144. By Natalia Bidart
-
All tests green, now for sure.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'tests/platform/linux/eventlog/test_zglog.py' | |||
2 | --- tests/platform/linux/eventlog/test_zglog.py 2011-06-15 21:14:06 +0000 | |||
3 | +++ tests/platform/linux/eventlog/test_zglog.py 2011-11-07 18:03:24 +0000 | |||
4 | @@ -25,7 +25,7 @@ | |||
5 | 25 | 25 | ||
6 | 26 | from distutils.spawn import find_executable | 26 | from distutils.spawn import find_executable |
7 | 27 | 27 | ||
9 | 28 | from twisted.internet.defer import Deferred | 28 | from twisted.internet.defer import Deferred, inlineCallbacks |
10 | 29 | from zeitgeist.client import ZeitgeistClient | 29 | from zeitgeist.client import ZeitgeistClient |
11 | 30 | from zeitgeist.datamodel import Event, Subject, Interpretation, Manifestation | 30 | from zeitgeist.datamodel import Event, Subject, Interpretation, Manifestation |
12 | 31 | 31 | ||
13 | @@ -92,8 +92,9 @@ | |||
14 | 92 | class ZeitgeistTestCase(DBusTwistedTestCase): | 92 | class ZeitgeistTestCase(DBusTwistedTestCase): |
15 | 93 | """Tests for the zeitgeist logging module.""" | 93 | """Tests for the zeitgeist logging module.""" |
16 | 94 | 94 | ||
17 | 95 | @inlineCallbacks | ||
18 | 95 | def setUp(self): | 96 | def setUp(self): |
20 | 96 | super(ZeitgeistTestCase, self).setUp() | 97 | yield super(ZeitgeistTestCase, self).setUp() |
21 | 97 | zgdaemon = find_executable("zeitgeist-daemon") | 98 | zgdaemon = find_executable("zeitgeist-daemon") |
22 | 98 | if not zgdaemon: | 99 | if not zgdaemon: |
23 | 99 | raise NotFoundError("zeitgeist-daemon was not found.") | 100 | raise NotFoundError("zeitgeist-daemon was not found.") |
24 | 100 | 101 | ||
25 | === modified file 'tests/platform/linux/test_dbus.py' | |||
26 | --- tests/platform/linux/test_dbus.py 2011-08-03 20:20:02 +0000 | |||
27 | +++ tests/platform/linux/test_dbus.py 2011-11-07 18:03:24 +0000 | |||
28 | @@ -2909,9 +2909,10 @@ | |||
29 | 2909 | self._old_home = os.environ['HOME'] | 2909 | self._old_home = os.environ['HOME'] |
30 | 2910 | os.environ['HOME'] = self.home_dir | 2910 | os.environ['HOME'] = self.home_dir |
31 | 2911 | 2911 | ||
32 | 2912 | @defer.inlineCallbacks | ||
33 | 2912 | def tearDown(self): | 2913 | def tearDown(self): |
34 | 2913 | os.environ['HOME'] = self._old_home | 2914 | os.environ['HOME'] = self._old_home |
36 | 2914 | return DBusTwistedTestCase.tearDown(self) | 2915 | yield super(FolderTests, self).tearDown() |
37 | 2915 | 2916 | ||
38 | 2916 | def _create_udf(self, id, node_id, suggested_path, subscribed=True): | 2917 | def _create_udf(self, id, node_id, suggested_path, subscribed=True): |
39 | 2917 | """Create an UDF and returns it and the volume.""" | 2918 | """Create an UDF and returns it and the volume.""" |
40 | 2918 | 2919 | ||
41 | === modified file 'tests/platform/linux/test_messaging.py' | |||
42 | --- tests/platform/linux/test_messaging.py 2011-03-29 22:47:53 +0000 | |||
43 | +++ tests/platform/linux/test_messaging.py 2011-11-07 18:03:24 +0000 | |||
44 | @@ -22,8 +22,7 @@ | |||
45 | 22 | """ | 22 | """ |
46 | 23 | 23 | ||
47 | 24 | 24 | ||
50 | 25 | from mocker import Mocker, ANY | 25 | from mocker import ANY, MockerTestCase as TestCase |
49 | 26 | from twisted.trial.unittest import TestCase | ||
51 | 27 | 26 | ||
52 | 28 | from ubuntuone.platform.linux.messaging import Messaging, _server_callback | 27 | from ubuntuone.platform.linux.messaging import Messaging, _server_callback |
53 | 29 | 28 | ||
54 | @@ -42,13 +41,6 @@ | |||
55 | 42 | class MessagingTestCase(TestCase): | 41 | class MessagingTestCase(TestCase): |
56 | 43 | """Test the Messaging API.""" | 42 | """Test the Messaging API.""" |
57 | 44 | 43 | ||
58 | 45 | def setUp(self): | ||
59 | 46 | self.mocker = Mocker() | ||
60 | 47 | |||
61 | 48 | def tearDown(self): | ||
62 | 49 | self.mocker.restore() | ||
63 | 50 | self.mocker.verify() | ||
64 | 51 | |||
65 | 52 | # pylint: disable=R0913 | 44 | # pylint: disable=R0913 |
66 | 53 | def _show_message_setup(self, message_time=None, message_count=None, | 45 | def _show_message_setup(self, message_time=None, message_count=None, |
67 | 54 | icon=None, update_count=None, real_callback=False): | 46 | icon=None, update_count=None, real_callback=False): |
68 | 55 | 47 | ||
69 | === modified file 'tests/platform/linux/test_notification.py' | |||
70 | --- tests/platform/linux/test_notification.py 2011-03-03 23:29:37 +0000 | |||
71 | +++ tests/platform/linux/test_notification.py 2011-11-07 18:03:24 +0000 | |||
72 | @@ -22,8 +22,7 @@ | |||
73 | 22 | """ | 22 | """ |
74 | 23 | 23 | ||
75 | 24 | 24 | ||
78 | 25 | from mocker import Mocker | 25 | from mocker import MockerTestCase as TestCase |
77 | 26 | from twisted.trial.unittest import TestCase | ||
79 | 27 | 26 | ||
80 | 28 | from ubuntuone.platform.linux.notification import Notification, ICON_NAME | 27 | from ubuntuone.platform.linux.notification import Notification, ICON_NAME |
81 | 29 | 28 | ||
82 | @@ -45,13 +44,6 @@ | |||
83 | 45 | class NotificationTestCase(TestCase): | 44 | class NotificationTestCase(TestCase): |
84 | 46 | """Test the Messaging API.""" | 45 | """Test the Messaging API.""" |
85 | 47 | 46 | ||
86 | 48 | def setUp(self): | ||
87 | 49 | self.mocker = Mocker() | ||
88 | 50 | |||
89 | 51 | def tearDown(self): | ||
90 | 52 | self.mocker.restore() | ||
91 | 53 | self.mocker.verify() | ||
92 | 54 | |||
93 | 55 | def test_send_notification(self): | 47 | def test_send_notification(self): |
94 | 56 | """On notification, pynotify receives the proper calls.""" | 48 | """On notification, pynotify receives the proper calls.""" |
95 | 57 | mock_notify = self.mocker.replace("pynotify") | 49 | mock_notify = self.mocker.replace("pynotify") |
96 | 58 | 50 | ||
97 | === modified file 'tests/platform/linux/test_unity.py' | |||
98 | --- tests/platform/linux/test_unity.py 2011-07-06 20:41:33 +0000 | |||
99 | +++ tests/platform/linux/test_unity.py 2011-11-07 18:03:24 +0000 | |||
100 | @@ -18,6 +18,7 @@ | |||
101 | 18 | 18 | ||
102 | 19 | """Tests for the liblauncher interface.""" | 19 | """Tests for the liblauncher interface.""" |
103 | 20 | 20 | ||
104 | 21 | from twisted.internet import defer | ||
105 | 21 | from twisted.trial.unittest import TestCase | 22 | from twisted.trial.unittest import TestCase |
106 | 22 | 23 | ||
107 | 23 | from ubuntuone.platform.linux import launcher | 24 | from ubuntuone.platform.linux import launcher |
108 | @@ -55,8 +56,10 @@ | |||
109 | 55 | 56 | ||
110 | 56 | skip = None if launcher.use_libunity else "libunity not installed." | 57 | skip = None if launcher.use_libunity else "libunity not installed." |
111 | 57 | 58 | ||
112 | 59 | @defer.inlineCallbacks | ||
113 | 58 | def setUp(self): | 60 | def setUp(self): |
114 | 59 | """Initialize this test instance.""" | 61 | """Initialize this test instance.""" |
115 | 62 | yield super(LauncherTestCase, self).setUp() | ||
116 | 60 | self.patch(launcher.Unity, "LauncherEntry", FakeLauncherEntry) | 63 | self.patch(launcher.Unity, "LauncherEntry", FakeLauncherEntry) |
117 | 61 | self.launcher = launcher.UbuntuOneLauncher() | 64 | self.launcher = launcher.UbuntuOneLauncher() |
118 | 62 | 65 | ||
119 | 63 | 66 | ||
120 | === modified file 'tests/platform/linux/test_vm.py' | |||
121 | --- tests/platform/linux/test_vm.py 2011-07-27 20:10:33 +0000 | |||
122 | +++ tests/platform/linux/test_vm.py 2011-11-07 18:03:24 +0000 | |||
123 | @@ -19,6 +19,8 @@ | |||
124 | 19 | import os | 19 | import os |
125 | 20 | import uuid | 20 | import uuid |
126 | 21 | 21 | ||
127 | 22 | from twisted.internet import defer | ||
128 | 23 | |||
129 | 22 | from contrib.testing.testcase import FakeMain, environ | 24 | from contrib.testing.testcase import FakeMain, environ |
130 | 23 | from tests.syncdaemon.test_vm import MetadataTestCase, BaseVolumeManagerTests | 25 | from tests.syncdaemon.test_vm import MetadataTestCase, BaseVolumeManagerTests |
131 | 24 | from ubuntuone.storageprotocol import request | 26 | from ubuntuone.storageprotocol import request |
132 | @@ -44,8 +46,9 @@ | |||
133 | 44 | class MetadataOldLayoutTests(MetadataTestCase): | 46 | class MetadataOldLayoutTests(MetadataTestCase): |
134 | 45 | """Tests for 'old' layouts and metadata upgrade""" | 47 | """Tests for 'old' layouts and metadata upgrade""" |
135 | 46 | 48 | ||
136 | 49 | @defer.inlineCallbacks | ||
137 | 47 | def setUp(self): | 50 | def setUp(self): |
139 | 48 | MetadataTestCase.setUp(self) | 51 | yield super(MetadataOldLayoutTests, self).setUp() |
140 | 49 | self.root_dir = os.path.join(self.u1_dir, 'My Files') | 52 | self.root_dir = os.path.join(self.u1_dir, 'My Files') |
141 | 50 | self.shares_dir = os.path.join(self.u1_dir, 'Shared With Me') | 53 | self.shares_dir = os.path.join(self.u1_dir, 'Shared With Me') |
142 | 51 | self.new_root_dir = self.u1_dir | 54 | self.new_root_dir = self.u1_dir |
143 | @@ -451,8 +454,9 @@ | |||
144 | 451 | class MetadataNewLayoutTests(MetadataTestCase): | 454 | class MetadataNewLayoutTests(MetadataTestCase): |
145 | 452 | """Test for 'new' layout and metadata upgrade.""" | 455 | """Test for 'new' layout and metadata upgrade.""" |
146 | 453 | 456 | ||
147 | 457 | @defer.inlineCallbacks | ||
148 | 454 | def setUp(self): | 458 | def setUp(self): |
150 | 455 | MetadataTestCase.setUp(self) | 459 | yield super(MetadataNewLayoutTests, self).setUp() |
151 | 456 | self.share_md_dir = os.path.join(self.vm_data_dir, 'shares') | 460 | self.share_md_dir = os.path.join(self.vm_data_dir, 'shares') |
152 | 457 | self.shared_md_dir = os.path.join(self.vm_data_dir, 'shared') | 461 | self.shared_md_dir = os.path.join(self.vm_data_dir, 'shared') |
153 | 458 | self.home_dir = os.path.join(self.tmpdir, 'home', 'ubuntuonehacker') | 462 | self.home_dir = os.path.join(self.tmpdir, 'home', 'ubuntuonehacker') |
154 | 459 | 463 | ||
155 | === modified file 'tests/platform/test_interaction_interfaces.py' | |||
156 | --- tests/platform/test_interaction_interfaces.py 2011-07-27 14:26:36 +0000 | |||
157 | +++ tests/platform/test_interaction_interfaces.py 2011-11-07 18:03:24 +0000 | |||
158 | @@ -18,15 +18,18 @@ | |||
159 | 18 | """Test that the interaction_interfaces are correctly called.""" | 18 | """Test that the interaction_interfaces are correctly called.""" |
160 | 19 | 19 | ||
161 | 20 | from mocker import MockerTestCase, MATCH | 20 | from mocker import MockerTestCase, MATCH |
162 | 21 | from twisted.internet import defer | ||
163 | 22 | |||
164 | 21 | from tests.platform import IPCTestCase | 23 | from tests.platform import IPCTestCase |
165 | 22 | 24 | ||
166 | 23 | 25 | ||
167 | 24 | class TestStatusIPC(MockerTestCase, IPCTestCase): | 26 | class TestStatusIPC(MockerTestCase, IPCTestCase): |
168 | 25 | """Ensure that calls are correctly fowarded.""" | 27 | """Ensure that calls are correctly fowarded.""" |
169 | 26 | 28 | ||
170 | 29 | @defer.inlineCallbacks | ||
171 | 27 | def setUp(self): | 30 | def setUp(self): |
172 | 28 | """Set up tests.""" | 31 | """Set up tests.""" |
174 | 29 | super(TestStatusIPC, self).setUp() | 32 | yield super(TestStatusIPC, self).setUp() |
175 | 30 | self.syncdaemon_status = self.mocker.mock() | 33 | self.syncdaemon_status = self.mocker.mock() |
176 | 31 | self.status.syncdaemon_status = self.syncdaemon_status | 34 | self.status.syncdaemon_status = self.syncdaemon_status |
177 | 32 | 35 | ||
178 | @@ -82,9 +85,10 @@ | |||
179 | 82 | class TestEventsIPC(MockerTestCase, IPCTestCase): | 85 | class TestEventsIPC(MockerTestCase, IPCTestCase): |
180 | 83 | """Ensure that calls are correctly fowarded.""" | 86 | """Ensure that calls are correctly fowarded.""" |
181 | 84 | 87 | ||
182 | 88 | @defer.inlineCallbacks | ||
183 | 85 | def setUp(self): | 89 | def setUp(self): |
184 | 86 | """Set up tests.""" | 90 | """Set up tests.""" |
186 | 87 | super(TestEventsIPC, self).setUp() | 91 | yield super(TestEventsIPC, self).setUp() |
187 | 88 | self.events_mock = self.mocker.mock() | 92 | self.events_mock = self.mocker.mock() |
188 | 89 | self.events.events = self.events_mock | 93 | self.events.events = self.events_mock |
189 | 90 | 94 | ||
190 | @@ -100,9 +104,10 @@ | |||
191 | 100 | class TestSyncDaemonIPC(MockerTestCase, IPCTestCase): | 104 | class TestSyncDaemonIPC(MockerTestCase, IPCTestCase): |
192 | 101 | """Ensure that calls are correctly fowarded.""" | 105 | """Ensure that calls are correctly fowarded.""" |
193 | 102 | 106 | ||
194 | 107 | @defer.inlineCallbacks | ||
195 | 103 | def setUp(self): | 108 | def setUp(self): |
196 | 104 | """Set up tests.""" | 109 | """Set up tests.""" |
198 | 105 | super(TestSyncDaemonIPC, self).setUp() | 110 | yield super(TestSyncDaemonIPC, self).setUp() |
199 | 106 | self.service = self.mocker.mock() | 111 | self.service = self.mocker.mock() |
200 | 107 | self.sync.service = self.service | 112 | self.sync.service = self.service |
201 | 108 | 113 | ||
202 | @@ -174,9 +179,10 @@ | |||
203 | 174 | class TestFileSystemIPC(MockerTestCase, IPCTestCase): | 179 | class TestFileSystemIPC(MockerTestCase, IPCTestCase): |
204 | 175 | """Ensure that calls are correctly fowarded.""" | 180 | """Ensure that calls are correctly fowarded.""" |
205 | 176 | 181 | ||
206 | 182 | @defer.inlineCallbacks | ||
207 | 177 | def setUp(self): | 183 | def setUp(self): |
208 | 178 | """Set up tests.""" | 184 | """Set up tests.""" |
210 | 179 | super(TestFileSystemIPC, self).setUp() | 185 | yield super(TestFileSystemIPC, self).setUp() |
211 | 180 | self.syncdaemon_filesystem = self.mocker.mock() | 186 | self.syncdaemon_filesystem = self.mocker.mock() |
212 | 181 | self.fs.syncdaemon_filesystem = self.syncdaemon_filesystem | 187 | self.fs.syncdaemon_filesystem = self.syncdaemon_filesystem |
213 | 182 | 188 | ||
214 | @@ -221,9 +227,10 @@ | |||
215 | 221 | class TestSharesIPC(MockerTestCase, IPCTestCase): | 227 | class TestSharesIPC(MockerTestCase, IPCTestCase): |
216 | 222 | """Ensure that calls are correctly fowarded.""" | 228 | """Ensure that calls are correctly fowarded.""" |
217 | 223 | 229 | ||
218 | 230 | @defer.inlineCallbacks | ||
219 | 224 | def setUp(self): | 231 | def setUp(self): |
220 | 225 | """Set up tests.""" | 232 | """Set up tests.""" |
222 | 226 | super(TestSharesIPC, self).setUp() | 233 | yield super(TestSharesIPC, self).setUp() |
223 | 227 | self.syncdaemon_shares = self.mocker.mock() | 234 | self.syncdaemon_shares = self.mocker.mock() |
224 | 228 | self.shares.syncdaemon_shares = self.syncdaemon_shares | 235 | self.shares.syncdaemon_shares = self.syncdaemon_shares |
225 | 229 | 236 | ||
226 | @@ -316,9 +323,10 @@ | |||
227 | 316 | class TestConfigIPC(MockerTestCase, IPCTestCase): | 323 | class TestConfigIPC(MockerTestCase, IPCTestCase): |
228 | 317 | """Ensure that calls are correctly fowarded.""" | 324 | """Ensure that calls are correctly fowarded.""" |
229 | 318 | 325 | ||
230 | 326 | @defer.inlineCallbacks | ||
231 | 319 | def setUp(self): | 327 | def setUp(self): |
232 | 320 | """Set up tests.""" | 328 | """Set up tests.""" |
234 | 321 | super(TestConfigIPC, self).setUp() | 329 | yield super(TestConfigIPC, self).setUp() |
235 | 322 | self.syncdaemon_config = self.mocker.mock() | 330 | self.syncdaemon_config = self.mocker.mock() |
236 | 323 | self.config.syncdaemon_config = self.syncdaemon_config | 331 | self.config.syncdaemon_config = self.syncdaemon_config |
237 | 324 | 332 | ||
238 | @@ -467,9 +475,10 @@ | |||
239 | 467 | class TestFoldersIPC(MockerTestCase, IPCTestCase): | 475 | class TestFoldersIPC(MockerTestCase, IPCTestCase): |
240 | 468 | """Ensure that calls are correctly fowarded.""" | 476 | """Ensure that calls are correctly fowarded.""" |
241 | 469 | 477 | ||
242 | 478 | @defer.inlineCallbacks | ||
243 | 470 | def setUp(self): | 479 | def setUp(self): |
244 | 471 | """Set up tests.""" | 480 | """Set up tests.""" |
246 | 472 | super(TestFoldersIPC, self).setUp() | 481 | yield super(TestFoldersIPC, self).setUp() |
247 | 473 | self.syncdaemon_folders = self.mocker.mock() | 482 | self.syncdaemon_folders = self.mocker.mock() |
248 | 474 | self.folders.syncdaemon_folders = self.syncdaemon_folders | 483 | self.folders.syncdaemon_folders = self.syncdaemon_folders |
249 | 475 | 484 | ||
250 | @@ -528,9 +537,10 @@ | |||
251 | 528 | class TestPublicFilesIPC(MockerTestCase, IPCTestCase): | 537 | class TestPublicFilesIPC(MockerTestCase, IPCTestCase): |
252 | 529 | """Ensure that calls are correctly fowarded.""" | 538 | """Ensure that calls are correctly fowarded.""" |
253 | 530 | 539 | ||
254 | 540 | @defer.inlineCallbacks | ||
255 | 531 | def setUp(self): | 541 | def setUp(self): |
256 | 532 | """Set up tests.""" | 542 | """Set up tests.""" |
258 | 533 | super(TestPublicFilesIPC, self).setUp() | 543 | yield super(TestPublicFilesIPC, self).setUp() |
259 | 534 | self.syncdaemon_public_files = self.mocker.mock() | 544 | self.syncdaemon_public_files = self.mocker.mock() |
260 | 535 | self.public_files.syncdaemon_public_files =\ | 545 | self.public_files.syncdaemon_public_files =\ |
261 | 536 | self.syncdaemon_public_files | 546 | self.syncdaemon_public_files |
262 | 537 | 547 | ||
263 | === modified file 'tests/status/test_aggregator.py' | |||
264 | --- tests/status/test_aggregator.py 2011-07-27 13:27:22 +0000 | |||
265 | +++ tests/status/test_aggregator.py 2011-11-07 18:03:24 +0000 | |||
266 | @@ -50,8 +50,10 @@ | |||
267 | 50 | 50 | ||
268 | 51 | TIMEOUT = 3.0 | 51 | TIMEOUT = 3.0 |
269 | 52 | 52 | ||
270 | 53 | @defer.inlineCallbacks | ||
271 | 53 | def setUp(self): | 54 | def setUp(self): |
272 | 54 | """Initialize this test instance.""" | 55 | """Initialize this test instance.""" |
273 | 56 | yield super(TimerTestCase, self).setUp() | ||
274 | 55 | self.clock = PatchedClock() | 57 | self.clock = PatchedClock() |
275 | 56 | self.timer = aggregator.Timer(delay=3.0, clock=self.clock) | 58 | self.timer = aggregator.Timer(delay=3.0, clock=self.clock) |
276 | 57 | 59 | ||
277 | @@ -101,8 +103,10 @@ | |||
278 | 101 | 103 | ||
279 | 102 | DELAY = 0.5 | 104 | DELAY = 0.5 |
280 | 103 | 105 | ||
281 | 106 | @defer.inlineCallbacks | ||
282 | 104 | def setUp(self): | 107 | def setUp(self): |
283 | 105 | """Initialize this test instance.""" | 108 | """Initialize this test instance.""" |
284 | 109 | yield super(DeadlineTimerTestCase, self).setUp() | ||
285 | 106 | self.clock = PatchedClock() | 110 | self.clock = PatchedClock() |
286 | 107 | self.timer = aggregator.DeadlineTimer(delay=0.5, timeout=3.0, | 111 | self.timer = aggregator.DeadlineTimer(delay=0.5, timeout=3.0, |
287 | 108 | clock=self.clock) | 112 | clock=self.clock) |
288 | @@ -242,8 +246,10 @@ | |||
289 | 242 | class ToggleableNotificationTestCase(TestCase): | 246 | class ToggleableNotificationTestCase(TestCase): |
290 | 243 | """Test the ToggleableNotification class.""" | 247 | """Test the ToggleableNotification class.""" |
291 | 244 | 248 | ||
292 | 249 | @defer.inlineCallbacks | ||
293 | 245 | def setUp(self): | 250 | def setUp(self): |
294 | 246 | """Initialize this test instance.""" | 251 | """Initialize this test instance.""" |
295 | 252 | yield super(ToggleableNotificationTestCase, self).setUp() | ||
296 | 247 | self.patch(aggregator, "Notification", FakeNotification) | 253 | self.patch(aggregator, "Notification", FakeNotification) |
297 | 248 | self.notification_switch = aggregator.NotificationSwitch() | 254 | self.notification_switch = aggregator.NotificationSwitch() |
298 | 249 | self.toggleable = self.notification_switch.get_notification() | 255 | self.toggleable = self.notification_switch.get_notification() |
299 | @@ -282,8 +288,10 @@ | |||
300 | 282 | class NotificationSwitchTestCase(TestCase): | 288 | class NotificationSwitchTestCase(TestCase): |
301 | 283 | """Test the NotificationSwitch class.""" | 289 | """Test the NotificationSwitch class.""" |
302 | 284 | 290 | ||
303 | 291 | @defer.inlineCallbacks | ||
304 | 285 | def setUp(self): | 292 | def setUp(self): |
305 | 286 | """Initialize this test instance.""" | 293 | """Initialize this test instance.""" |
306 | 294 | yield super(NotificationSwitchTestCase, self).setUp() | ||
307 | 287 | self.notification_switch = aggregator.NotificationSwitch() | 295 | self.notification_switch = aggregator.NotificationSwitch() |
308 | 288 | 296 | ||
309 | 289 | def test_get_notification(self): | 297 | def test_get_notification(self): |
310 | @@ -306,8 +314,10 @@ | |||
311 | 306 | class FileDiscoveryBubbleTestCase(TestCase): | 314 | class FileDiscoveryBubbleTestCase(TestCase): |
312 | 307 | """Test the FileDiscoveryBubble class.""" | 315 | """Test the FileDiscoveryBubble class.""" |
313 | 308 | 316 | ||
314 | 317 | @defer.inlineCallbacks | ||
315 | 309 | def setUp(self): | 318 | def setUp(self): |
316 | 310 | """Initialize this test instance.""" | 319 | """Initialize this test instance.""" |
317 | 320 | yield super(FileDiscoveryBubbleTestCase, self).setUp() | ||
318 | 311 | self.patch(aggregator, "ToggleableNotification", | 321 | self.patch(aggregator, "ToggleableNotification", |
319 | 312 | FakeNotificationSingleton()) | 322 | FakeNotificationSingleton()) |
320 | 313 | self.clock = PatchedClock() | 323 | self.clock = PatchedClock() |
321 | @@ -487,8 +497,10 @@ | |||
322 | 487 | class FinalBubbleTestCase(TestCase): | 497 | class FinalBubbleTestCase(TestCase): |
323 | 488 | """Test for the final status notification bubble.""" | 498 | """Test for the final status notification bubble.""" |
324 | 489 | 499 | ||
325 | 500 | @defer.inlineCallbacks | ||
326 | 490 | def setUp(self): | 501 | def setUp(self): |
327 | 491 | """Initialize this test instance.""" | 502 | """Initialize this test instance.""" |
328 | 503 | yield super(FinalBubbleTestCase, self).setUp() | ||
329 | 492 | self.patch(aggregator, "ToggleableNotification", | 504 | self.patch(aggregator, "ToggleableNotification", |
330 | 493 | FakeNotificationSingleton()) | 505 | FakeNotificationSingleton()) |
331 | 494 | self.clock = PatchedClock() | 506 | self.clock = PatchedClock() |
332 | @@ -542,8 +554,10 @@ | |||
333 | 542 | class ProgressBarTestCase(TestCase): | 554 | class ProgressBarTestCase(TestCase): |
334 | 543 | """Tests for the progress bar.""" | 555 | """Tests for the progress bar.""" |
335 | 544 | 556 | ||
336 | 557 | @defer.inlineCallbacks | ||
337 | 545 | def setUp(self): | 558 | def setUp(self): |
338 | 546 | """Initialize this test instance.""" | 559 | """Initialize this test instance.""" |
339 | 560 | yield super(ProgressBarTestCase, self).setUp() | ||
340 | 547 | self.patch(aggregator, "UbuntuOneLauncher", FakeLauncher) | 561 | self.patch(aggregator, "UbuntuOneLauncher", FakeLauncher) |
341 | 548 | self.patch(aggregator.session, "Inhibitor", FakeInhibitor) | 562 | self.patch(aggregator.session, "Inhibitor", FakeInhibitor) |
342 | 549 | self.clock = PatchedClock() | 563 | self.clock = PatchedClock() |
343 | @@ -737,10 +751,10 @@ | |||
344 | 737 | self.files_uploading.remove(command) | 751 | self.files_uploading.remove(command) |
345 | 738 | self.queued_commands.discard(command) | 752 | self.queued_commands.discard(command) |
346 | 739 | 753 | ||
348 | 740 | def progress_made(self, share_id, node_id, n_bytes_written, deflated_size): | 754 | def progress_made(self, share_id, node_id, n_bytes, deflated_size): |
349 | 741 | """Progress made on up- or download.""" | 755 | """Progress made on up- or download.""" |
350 | 742 | self.progress_events.append( | 756 | self.progress_events.append( |
352 | 743 | (share_id, node_id, n_bytes_written, deflated_size)) | 757 | (share_id, node_id, n_bytes, deflated_size)) |
353 | 744 | 758 | ||
354 | 745 | def connection_made(self): | 759 | def connection_made(self): |
355 | 746 | """The client made the connection to the server.""" | 760 | """The client made the connection to the server.""" |
356 | @@ -1033,8 +1047,10 @@ | |||
357 | 1033 | CLASS_KWARGS = {} | 1047 | CLASS_KWARGS = {} |
358 | 1034 | status = None | 1048 | status = None |
359 | 1035 | 1049 | ||
360 | 1050 | @defer.inlineCallbacks | ||
361 | 1036 | def setUp(self): | 1051 | def setUp(self): |
362 | 1037 | """Initialize this test instance.""" | 1052 | """Initialize this test instance.""" |
363 | 1053 | yield super(StatusEventTestCase, self).setUp() | ||
364 | 1038 | if type(self) == StatusEventTestCase: | 1054 | if type(self) == StatusEventTestCase: |
365 | 1039 | self.assertRaises(AssertionError, self.CLASS, **self.CLASS_KWARGS) | 1055 | self.assertRaises(AssertionError, self.CLASS, **self.CLASS_KWARGS) |
366 | 1040 | else: | 1056 | else: |
367 | @@ -1177,8 +1193,10 @@ | |||
368 | 1177 | class StatusAggregatorTestCase(TestCase): | 1193 | class StatusAggregatorTestCase(TestCase): |
369 | 1178 | """Test the backend of the status aggregator.""" | 1194 | """Test the backend of the status aggregator.""" |
370 | 1179 | 1195 | ||
371 | 1196 | @defer.inlineCallbacks | ||
372 | 1180 | def setUp(self): | 1197 | def setUp(self): |
373 | 1181 | """Initialize this test instance.""" | 1198 | """Initialize this test instance.""" |
374 | 1199 | yield super(StatusAggregatorTestCase, self).setUp() | ||
375 | 1182 | self.patch(aggregator, "FileDiscoveryBubble", | 1200 | self.patch(aggregator, "FileDiscoveryBubble", |
376 | 1183 | FakeFileDiscoveryBubble) | 1201 | FakeFileDiscoveryBubble) |
377 | 1184 | self.patch(aggregator, "FinalStatusBubble", | 1202 | self.patch(aggregator, "FinalStatusBubble", |
378 | 1185 | 1203 | ||
379 | === modified file 'tests/syncdaemon/test_action_queue.py' | |||
380 | --- tests/syncdaemon/test_action_queue.py 2011-09-08 21:29:37 +0000 | |||
381 | +++ tests/syncdaemon/test_action_queue.py 2011-11-07 18:03:24 +0000 | |||
382 | @@ -104,11 +104,19 @@ | |||
383 | 104 | return self.check(logger.NOTE, *msgs) | 104 | return self.check(logger.NOTE, *msgs) |
384 | 105 | 105 | ||
385 | 106 | 106 | ||
386 | 107 | class FakeMagicHash(object): | ||
387 | 108 | """Fake magic hash.""" | ||
388 | 109 | _magic_hash = '666' | ||
389 | 110 | |||
390 | 111 | |||
391 | 107 | class FakeTempFile(object): | 112 | class FakeTempFile(object): |
392 | 108 | """Fake temporary file.""" | 113 | """Fake temporary file.""" |
393 | 114 | |||
394 | 109 | def __init__(self, tmpdir): | 115 | def __init__(self, tmpdir): |
395 | 116 | self.closed = 0 # be able to count how may close calls we had | ||
396 | 110 | self.name = os.path.join(tmpdir, 'remove-me.zip') | 117 | self.name = os.path.join(tmpdir, 'remove-me.zip') |
397 | 111 | open_file(self.name, 'w').close() | 118 | open_file(self.name, 'w').close() |
398 | 119 | self.close = lambda: setattr(self, 'closed', self.closed + 1) | ||
399 | 112 | 120 | ||
400 | 113 | 121 | ||
401 | 114 | class FakeCommand(object): | 122 | class FakeCommand(object): |
402 | @@ -181,7 +189,7 @@ | |||
403 | 181 | 189 | ||
404 | 182 | class FakeRequest(object): | 190 | class FakeRequest(object): |
405 | 183 | """Fake Request.""" | 191 | """Fake Request.""" |
407 | 184 | def __init__(self): | 192 | def __init__(self, *a, **k): |
408 | 185 | self.deferred = defer.succeed(True) | 193 | self.deferred = defer.succeed(True) |
409 | 186 | self.cancelled = False | 194 | self.cancelled = False |
410 | 187 | 195 | ||
411 | @@ -442,8 +450,10 @@ | |||
412 | 442 | class TestRequestQueue(TwistedTestCase): | 450 | class TestRequestQueue(TwistedTestCase): |
413 | 443 | """Tests for the RequestQueue.""" | 451 | """Tests for the RequestQueue.""" |
414 | 444 | 452 | ||
415 | 453 | @defer.inlineCallbacks | ||
416 | 445 | def setUp(self): | 454 | def setUp(self): |
417 | 446 | """Set up.""" | 455 | """Set up.""" |
418 | 456 | yield super(TestRequestQueue, self).setUp() | ||
419 | 447 | 457 | ||
420 | 448 | class FakeAQ(object): | 458 | class FakeAQ(object): |
421 | 449 | """Fake AQ.""" | 459 | """Fake AQ.""" |
422 | @@ -765,8 +775,10 @@ | |||
423 | 765 | class TestDeferredMap(TwistedTestCase): | 775 | class TestDeferredMap(TwistedTestCase): |
424 | 766 | """Test the deferred map.""" | 776 | """Test the deferred map.""" |
425 | 767 | 777 | ||
426 | 778 | @defer.inlineCallbacks | ||
427 | 768 | def setUp(self): | 779 | def setUp(self): |
428 | 769 | """Set up.""" | 780 | """Set up.""" |
429 | 781 | yield super(TestDeferredMap, self).setUp() | ||
430 | 770 | self.dm = DeferredMap() | 782 | self.dm = DeferredMap() |
431 | 771 | 783 | ||
432 | 772 | def test_one_get_returns_stored_deferred(self): | 784 | def test_one_get_returns_stored_deferred(self): |
433 | @@ -853,8 +865,10 @@ | |||
434 | 853 | class TestZipQueue(TwistedTestCase): | 865 | class TestZipQueue(TwistedTestCase): |
435 | 854 | """Test the zipping queue.""" | 866 | """Test the zipping queue.""" |
436 | 855 | 867 | ||
437 | 868 | @defer.inlineCallbacks | ||
438 | 856 | def setUp(self): | 869 | def setUp(self): |
439 | 857 | """Set up.""" | 870 | """Set up.""" |
440 | 871 | yield super(TestZipQueue, self).setUp() | ||
441 | 858 | self.zq = ZipQueue() | 872 | self.zq = ZipQueue() |
442 | 859 | 873 | ||
443 | 860 | @defer.inlineCallbacks | 874 | @defer.inlineCallbacks |
444 | @@ -3053,9 +3067,7 @@ | |||
445 | 3053 | def test_fileobj_in_run(self): | 3067 | def test_fileobj_in_run(self): |
446 | 3054 | """Create it first time, reset after that.""" | 3068 | """Create it first time, reset after that.""" |
447 | 3055 | # don't use the real protocol | 3069 | # don't use the real protocol |
451 | 3056 | obj = Mocker().mock() | 3070 | self.action_queue.client.get_content_request = FakeRequest |
449 | 3057 | obj.deferred | ||
450 | 3058 | self.action_queue.client.get_content_request = lambda *a, **k: obj | ||
452 | 3059 | 3071 | ||
453 | 3060 | class FakeFileObjFactory(object): | 3072 | class FakeFileObjFactory(object): |
454 | 3061 | """Fake class to check behaviour.""" | 3073 | """Fake class to check behaviour.""" |
455 | @@ -3099,10 +3111,6 @@ | |||
456 | 3099 | """Init.""" | 3111 | """Init.""" |
457 | 3100 | yield super(UploadUnconnectedTestCase, self).setUp() | 3112 | yield super(UploadUnconnectedTestCase, self).setUp() |
458 | 3101 | 3113 | ||
459 | 3102 | class FakeMagicHash(object): | ||
460 | 3103 | """Fake magic hash.""" | ||
461 | 3104 | _magic_hash = '666' | ||
462 | 3105 | |||
463 | 3106 | self.rq = request_queue = RequestQueue(action_queue=self.action_queue) | 3114 | self.rq = request_queue = RequestQueue(action_queue=self.action_queue) |
464 | 3107 | self.command = Upload(request_queue, share_id='a_share_id', | 3115 | self.command = Upload(request_queue, share_id='a_share_id', |
465 | 3108 | node_id='a_node_id', previous_hash='prev_hash', | 3116 | node_id='a_node_id', previous_hash='prev_hash', |
466 | @@ -3116,6 +3124,7 @@ | |||
467 | 3116 | def test_upload_progress_wrapper_setup(self): | 3124 | def test_upload_progress_wrapper_setup(self): |
468 | 3117 | """Test the setting up of the progress wrapper in ._run().""" | 3125 | """Test the setting up of the progress wrapper in ._run().""" |
469 | 3118 | self.command.action_queue.connect_in_progress = False | 3126 | self.command.action_queue.connect_in_progress = False |
470 | 3127 | self.command.tempfile = StringIO() | ||
471 | 3119 | self.command._run() | 3128 | self.command._run() |
472 | 3120 | 3129 | ||
473 | 3121 | self.assertEqual(len(self.client.called), 1) | 3130 | self.assertEqual(len(self.client.called), 1) |
474 | @@ -3306,16 +3315,29 @@ | |||
475 | 3306 | events = [('AQ_UPLOAD_ERROR', kwargs)] | 3315 | events = [('AQ_UPLOAD_ERROR', kwargs)] |
476 | 3307 | self.assertEqual(events, self.command.action_queue.event_queue.events) | 3316 | self.assertEqual(events, self.command.action_queue.event_queue.events) |
477 | 3308 | 3317 | ||
480 | 3309 | def test_handle_failure_removes_temp_file(self): | 3318 | def test_finish_closes_temp_file(self): |
481 | 3310 | """Test temp file is removed on failure.""" | 3319 | """Test temp file is closed when the command finishes.""" |
482 | 3320 | self.command.tempfile = FakeTempFile(self.tmpdir) | ||
483 | 3321 | assert self.command.tempfile.closed == 0 | ||
484 | 3322 | |||
485 | 3323 | self.command.finish() | ||
486 | 3324 | self.assertEqual(1, self.command.tempfile.closed) | ||
487 | 3325 | |||
488 | 3326 | def test_finish_removes_temp_file(self): | ||
489 | 3327 | """Test temp file is removed when the command finishes.""" | ||
490 | 3311 | self.command.tempfile = FakeTempFile(self.tmpdir) | 3328 | self.command.tempfile = FakeTempFile(self.tmpdir) |
491 | 3312 | assert path_exists(self.command.tempfile.name) | 3329 | assert path_exists(self.command.tempfile.name) |
492 | 3313 | 3330 | ||
496 | 3314 | msg = 'Something went wrong' | 3331 | self.command.finish() |
494 | 3315 | failure = Failure(DefaultException(msg)) | ||
495 | 3316 | self.command.handle_failure(failure=failure) | ||
497 | 3317 | self.assertFalse(path_exists(self.command.tempfile.name)) | 3332 | self.assertFalse(path_exists(self.command.tempfile.name)) |
498 | 3318 | 3333 | ||
499 | 3334 | def test_finish_handles_temp_file_none(self): | ||
500 | 3335 | """Test temp file can be None when calling finish.""" | ||
501 | 3336 | self.command.tempfile = None | ||
502 | 3337 | |||
503 | 3338 | self.command.finish() | ||
504 | 3339 | self.assertEqual(self.command.tempfile, None) # nothing changed | ||
505 | 3340 | |||
506 | 3319 | def test_retryable_failure_push_quota_exceeded_if_that_error(self): | 3341 | def test_retryable_failure_push_quota_exceeded_if_that_error(self): |
507 | 3320 | """Test SYS_QUOTA_EXCEEDED is pushed on QuotaExceededError.""" | 3342 | """Test SYS_QUOTA_EXCEEDED is pushed on QuotaExceededError.""" |
508 | 3321 | protocol_msg = protocol_pb2.Message() | 3343 | protocol_msg = protocol_pb2.Message() |
509 | @@ -3641,6 +3663,18 @@ | |||
510 | 3641 | tempfile = NamedTemporaryFile() | 3663 | tempfile = NamedTemporaryFile() |
511 | 3642 | self.assertEqual(tempfile.mode, 'w+b') | 3664 | self.assertEqual(tempfile.mode, 'w+b') |
512 | 3643 | 3665 | ||
513 | 3666 | def test_fileobj_in_run(self): | ||
514 | 3667 | """Create it first time, reset after that.""" | ||
515 | 3668 | # don't use the real protocol or magic hash | ||
516 | 3669 | self.action_queue.client.put_content_request = FakeRequest | ||
517 | 3670 | self.command.magic_hash = FakeMagicHash() | ||
518 | 3671 | |||
519 | 3672 | called = [] | ||
520 | 3673 | self.command.tempfile = StringIO() | ||
521 | 3674 | self.command.tempfile.seek = lambda *a: called.extend(a) | ||
522 | 3675 | self.command._run() | ||
523 | 3676 | self.assertEqual(called, [0]) | ||
524 | 3677 | |||
525 | 3644 | 3678 | ||
526 | 3645 | class CreateShareTestCase(ConnectedBaseTestCase): | 3679 | class CreateShareTestCase(ConnectedBaseTestCase): |
527 | 3646 | """Test for CreateShare ActionQueueCommand.""" | 3680 | """Test for CreateShare ActionQueueCommand.""" |
528 | @@ -4919,8 +4953,10 @@ | |||
529 | 4919 | class ActionQueueProtocolTests(TwistedTestCase): | 4953 | class ActionQueueProtocolTests(TwistedTestCase): |
530 | 4920 | """Test the ACQ class.""" | 4954 | """Test the ACQ class.""" |
531 | 4921 | 4955 | ||
532 | 4956 | @defer.inlineCallbacks | ||
533 | 4922 | def setUp(self): | 4957 | def setUp(self): |
534 | 4923 | """Set up.""" | 4958 | """Set up.""" |
535 | 4959 | yield super(ActionQueueProtocolTests, self).setUp() | ||
536 | 4924 | # create an AQP and put a factory to it | 4960 | # create an AQP and put a factory to it |
537 | 4925 | self.aqp = ActionQueueProtocol() | 4961 | self.aqp = ActionQueueProtocol() |
538 | 4926 | obj = Mocker().mock() | 4962 | obj = Mocker().mock() |
539 | @@ -4932,8 +4968,10 @@ | |||
540 | 4932 | self.handler.setLevel(logging.DEBUG) | 4968 | self.handler.setLevel(logging.DEBUG) |
541 | 4933 | self.aqp.log.addHandler(self.handler) | 4969 | self.aqp.log.addHandler(self.handler) |
542 | 4934 | 4970 | ||
543 | 4971 | @defer.inlineCallbacks | ||
544 | 4935 | def tearDown(self): | 4972 | def tearDown(self): |
545 | 4936 | """Tear down.""" | 4973 | """Tear down.""" |
546 | 4974 | yield super(ActionQueueProtocolTests, self).tearDown() | ||
547 | 4937 | self.aqp.log.removeHandler(self.handler) | 4975 | self.aqp.log.removeHandler(self.handler) |
548 | 4938 | if self.aqp.ping_manager is not None: | 4976 | if self.aqp.ping_manager is not None: |
549 | 4939 | self.aqp.ping_manager.stop() | 4977 | self.aqp.ping_manager.stop() |
550 | @@ -5541,8 +5579,10 @@ | |||
551 | 5541 | class ConditionsLockerTests(TwistedTestCase): | 5579 | class ConditionsLockerTests(TwistedTestCase): |
552 | 5542 | """Test the ConditionsLocker.""" | 5580 | """Test the ConditionsLocker.""" |
553 | 5543 | 5581 | ||
554 | 5582 | @defer.inlineCallbacks | ||
555 | 5544 | def setUp(self): | 5583 | def setUp(self): |
556 | 5545 | """Set up.""" | 5584 | """Set up.""" |
557 | 5585 | yield super(ConditionsLockerTests, self).setUp() | ||
558 | 5546 | self.cl = ConditionsLocker() | 5586 | self.cl = ConditionsLocker() |
559 | 5547 | 5587 | ||
560 | 5548 | def test_get_locking_deferred_returns_deferred(self): | 5588 | def test_get_locking_deferred_returns_deferred(self): |
561 | @@ -5664,8 +5704,11 @@ | |||
562 | 5664 | class PingManagerTestCase(TwistedTestCase): | 5704 | class PingManagerTestCase(TwistedTestCase): |
563 | 5665 | """Test the Ping manager.""" | 5705 | """Test the Ping manager.""" |
564 | 5666 | 5706 | ||
565 | 5707 | @defer.inlineCallbacks | ||
566 | 5667 | def setUp(self): | 5708 | def setUp(self): |
567 | 5668 | """Set up.""" | 5709 | """Set up.""" |
568 | 5710 | yield super(PingManagerTestCase, self).setUp() | ||
569 | 5711 | |||
570 | 5669 | class FakeActionQueueProtocol(object): | 5712 | class FakeActionQueueProtocol(object): |
571 | 5670 | """Fake object for the tests.""" | 5713 | """Fake object for the tests.""" |
572 | 5671 | log = logging.getLogger("ubuntuone.SyncDaemon.ActionQueue") | 5714 | log = logging.getLogger("ubuntuone.SyncDaemon.ActionQueue") |
573 | @@ -5677,8 +5720,10 @@ | |||
574 | 5677 | self.fake_aqp.log.addHandler(self.handler) | 5720 | self.fake_aqp.log.addHandler(self.handler) |
575 | 5678 | self.pm = PingManager(self.fake_aqp) | 5721 | self.pm = PingManager(self.fake_aqp) |
576 | 5679 | 5722 | ||
577 | 5723 | @defer.inlineCallbacks | ||
578 | 5680 | def tearDown(self): | 5724 | def tearDown(self): |
579 | 5681 | """Tear down.""" | 5725 | """Tear down.""" |
580 | 5726 | yield super(PingManagerTestCase, self).tearDown() | ||
581 | 5682 | self.fake_aqp.log.removeHandler(self.handler) | 5727 | self.fake_aqp.log.removeHandler(self.handler) |
582 | 5683 | self.pm.stop() | 5728 | self.pm.stop() |
583 | 5684 | 5729 | ||
584 | 5685 | 5730 | ||
585 | === modified file 'tests/syncdaemon/test_logger.py' | |||
586 | --- tests/syncdaemon/test_logger.py 2011-08-10 12:01:01 +0000 | |||
587 | +++ tests/syncdaemon/test_logger.py 2011-11-07 18:03:24 +0000 | |||
588 | @@ -20,6 +20,7 @@ | |||
589 | 20 | 20 | ||
590 | 21 | import logging | 21 | import logging |
591 | 22 | 22 | ||
592 | 23 | from twisted.internet import defer | ||
593 | 23 | from twisted.trial import unittest | 24 | from twisted.trial import unittest |
594 | 24 | 25 | ||
595 | 25 | from ubuntuone.devtools.handlers import MementoHandler | 26 | from ubuntuone.devtools.handlers import MementoHandler |
596 | @@ -39,15 +40,19 @@ | |||
597 | 39 | class DebugCaptureTest(unittest.TestCase): | 40 | class DebugCaptureTest(unittest.TestCase): |
598 | 40 | """Tests for DebugCapture context manager.""" | 41 | """Tests for DebugCapture context manager.""" |
599 | 41 | 42 | ||
600 | 43 | @defer.inlineCallbacks | ||
601 | 42 | def setUp(self): | 44 | def setUp(self): |
602 | 43 | """Setup the logger and the handler""" | 45 | """Setup the logger and the handler""" |
603 | 46 | yield super(DebugCaptureTest, self).setUp() | ||
604 | 44 | self.handler = MementoHandler() | 47 | self.handler = MementoHandler() |
605 | 45 | self.logger = logging.getLogger(self.__class__.__name__) | 48 | self.logger = logging.getLogger(self.__class__.__name__) |
606 | 46 | self.logger.addHandler(self.handler) | 49 | self.logger.addHandler(self.handler) |
607 | 47 | self.logger.setLevel(logging.DEBUG) | 50 | self.logger.setLevel(logging.DEBUG) |
608 | 48 | 51 | ||
609 | 52 | @defer.inlineCallbacks | ||
610 | 49 | def tearDown(self): | 53 | def tearDown(self): |
611 | 50 | """close the handler and restore the logger (Logger's are global)""" | 54 | """close the handler and restore the logger (Logger's are global)""" |
612 | 55 | yield super(DebugCaptureTest, self).tearDown() | ||
613 | 51 | self.handler.close() | 56 | self.handler.close() |
614 | 52 | self.logger.removeHandler(self.handler) | 57 | self.logger.removeHandler(self.handler) |
615 | 53 | self.logger.setLevel(logging.DEBUG) | 58 | self.logger.setLevel(logging.DEBUG) |
616 | @@ -222,8 +227,10 @@ | |||
617 | 222 | class FilterTests(unittest.TestCase): | 227 | class FilterTests(unittest.TestCase): |
618 | 223 | """Tests log filters""" | 228 | """Tests log filters""" |
619 | 224 | 229 | ||
620 | 230 | @defer.inlineCallbacks | ||
621 | 225 | def setUp(self): | 231 | def setUp(self): |
622 | 226 | """Setup the logger and the handler""" | 232 | """Setup the logger and the handler""" |
623 | 233 | yield super(FilterTests, self).setUp() | ||
624 | 227 | self.handler = MementoHandler() | 234 | self.handler = MementoHandler() |
625 | 228 | self.handler.setLevel(logging.DEBUG) | 235 | self.handler.setLevel(logging.DEBUG) |
626 | 229 | root_logger.addHandler(self.handler) | 236 | root_logger.addHandler(self.handler) |
627 | @@ -253,15 +260,19 @@ | |||
628 | 253 | class MultiFilterTest(unittest.TestCase): | 260 | class MultiFilterTest(unittest.TestCase): |
629 | 254 | """Tests for logger.MultiFilter""" | 261 | """Tests for logger.MultiFilter""" |
630 | 255 | 262 | ||
631 | 263 | @defer.inlineCallbacks | ||
632 | 256 | def setUp(self): | 264 | def setUp(self): |
633 | 257 | """Setup the logger and the handler""" | 265 | """Setup the logger and the handler""" |
634 | 266 | yield super(MultiFilterTest, self).setUp() | ||
635 | 258 | self.handler = MementoHandler() | 267 | self.handler = MementoHandler() |
636 | 259 | self.logger = logging.getLogger(self.__class__.__name__) | 268 | self.logger = logging.getLogger(self.__class__.__name__) |
637 | 260 | self.logger.addHandler(self.handler) | 269 | self.logger.addHandler(self.handler) |
638 | 261 | self.logger.setLevel(logging.DEBUG) | 270 | self.logger.setLevel(logging.DEBUG) |
639 | 262 | 271 | ||
640 | 272 | @defer.inlineCallbacks | ||
641 | 263 | def tearDown(self): | 273 | def tearDown(self): |
642 | 264 | """close the handler and restore the logger (Logger's are global)""" | 274 | """close the handler and restore the logger (Logger's are global)""" |
643 | 275 | yield super(MultiFilterTest, self).tearDown() | ||
644 | 265 | self.handler.close() | 276 | self.handler.close() |
645 | 266 | self.logger.removeHandler(self.handler) | 277 | self.logger.removeHandler(self.handler) |
646 | 267 | self.logger.setLevel(logging.DEBUG) | 278 | self.logger.setLevel(logging.DEBUG) |
647 | 268 | 279 | ||
648 | === modified file 'tests/syncdaemon/test_pathlockingtree.py' | |||
649 | --- tests/syncdaemon/test_pathlockingtree.py 2011-01-20 21:27:24 +0000 | |||
650 | +++ tests/syncdaemon/test_pathlockingtree.py 2011-11-07 18:03:24 +0000 | |||
651 | @@ -29,8 +29,10 @@ | |||
652 | 29 | class InternalDeferredTests(TwistedTestCase): | 29 | class InternalDeferredTests(TwistedTestCase): |
653 | 30 | """Test the internal deferreds handling functionality.""" | 30 | """Test the internal deferreds handling functionality.""" |
654 | 31 | 31 | ||
655 | 32 | @defer.inlineCallbacks | ||
656 | 32 | def setUp(self): | 33 | def setUp(self): |
657 | 33 | """Set up.""" | 34 | """Set up.""" |
658 | 35 | yield super(InternalDeferredTests, self).setUp() | ||
659 | 34 | self.plt = PathLockingTree() | 36 | self.plt = PathLockingTree() |
660 | 35 | 37 | ||
661 | 36 | def test_single_element_old(self): | 38 | def test_single_element_old(self): |
662 | @@ -217,8 +219,10 @@ | |||
663 | 217 | class LockingTests(TwistedTestCase): | 219 | class LockingTests(TwistedTestCase): |
664 | 218 | """Test the locking between elements.""" | 220 | """Test the locking between elements.""" |
665 | 219 | 221 | ||
666 | 222 | @defer.inlineCallbacks | ||
667 | 220 | def setUp(self): | 223 | def setUp(self): |
668 | 221 | """Set up.""" | 224 | """Set up.""" |
669 | 225 | yield super(LockingTests, self).setUp() | ||
670 | 222 | self.plt = PathLockingTree() | 226 | self.plt = PathLockingTree() |
671 | 223 | 227 | ||
672 | 224 | @defer.inlineCallbacks | 228 | @defer.inlineCallbacks |
673 | @@ -417,8 +421,10 @@ | |||
674 | 417 | class CleaningTests(TwistedTestCase): | 421 | class CleaningTests(TwistedTestCase): |
675 | 418 | """Test that the releases clean the tree.""" | 422 | """Test that the releases clean the tree.""" |
676 | 419 | 423 | ||
677 | 424 | @defer.inlineCallbacks | ||
678 | 420 | def setUp(self): | 425 | def setUp(self): |
679 | 421 | """Set up.""" | 426 | """Set up.""" |
680 | 427 | yield super(CleaningTests, self).setUp() | ||
681 | 422 | self.plt = PathLockingTree() | 428 | self.plt = PathLockingTree() |
682 | 423 | 429 | ||
683 | 424 | @defer.inlineCallbacks | 430 | @defer.inlineCallbacks |
684 | @@ -547,8 +553,10 @@ | |||
685 | 547 | class LoggingTests(TwistedTestCase): | 553 | class LoggingTests(TwistedTestCase): |
686 | 548 | """Test the logging.""" | 554 | """Test the logging.""" |
687 | 549 | 555 | ||
688 | 556 | @defer.inlineCallbacks | ||
689 | 550 | def setUp(self): | 557 | def setUp(self): |
690 | 551 | """Set up.""" | 558 | """Set up.""" |
691 | 559 | yield super(LoggingTests, self).setUp() | ||
692 | 552 | self.plt = PathLockingTree() | 560 | self.plt = PathLockingTree() |
693 | 553 | 561 | ||
694 | 554 | self.handler = MementoHandler() | 562 | self.handler = MementoHandler() |
695 | 555 | 563 | ||
696 | === modified file 'tests/syncdaemon/test_states.py' | |||
697 | --- tests/syncdaemon/test_states.py 2011-01-18 20:25:54 +0000 | |||
698 | +++ tests/syncdaemon/test_states.py 2011-11-07 18:03:24 +0000 | |||
699 | @@ -107,7 +107,9 @@ | |||
700 | 107 | class Base(TwistedTestCase): | 107 | class Base(TwistedTestCase): |
701 | 108 | """Base class for state tests.""" | 108 | """Base class for state tests.""" |
702 | 109 | 109 | ||
703 | 110 | @defer.inlineCallbacks | ||
704 | 110 | def setUp(self): | 111 | def setUp(self): |
705 | 112 | yield super(Base, self).setUp() | ||
706 | 111 | # create fake classes | 113 | # create fake classes |
707 | 112 | self.eq = FakeEventQueue() | 114 | self.eq = FakeEventQueue() |
708 | 113 | self.aq = FakeActionQueue() | 115 | self.aq = FakeActionQueue() |
709 | @@ -157,15 +159,18 @@ | |||
710 | 157 | reactor.callLater(.1, check, 0) | 159 | reactor.callLater(.1, check, 0) |
711 | 158 | return d | 160 | return d |
712 | 159 | 161 | ||
713 | 162 | @defer.inlineCallbacks | ||
714 | 160 | def tearDown(self): | 163 | def tearDown(self): |
715 | 164 | yield super(Base, self).tearDown() | ||
716 | 161 | self.sm.connection.shutdown() | 165 | self.sm.connection.shutdown() |
717 | 162 | 166 | ||
718 | 163 | 167 | ||
719 | 164 | class QueueBase(Base): | 168 | class QueueBase(Base): |
720 | 165 | """Basic setup for QueueManager.""" | 169 | """Basic setup for QueueManager.""" |
721 | 166 | 170 | ||
722 | 171 | @defer.inlineCallbacks | ||
723 | 167 | def setUp(self): | 172 | def setUp(self): |
725 | 168 | Base.setUp(self) | 173 | yield super(QueueBase, self).setUp() |
726 | 169 | self.sm.state = StateManager.QUEUE_MANAGER | 174 | self.sm.state = StateManager.QUEUE_MANAGER |
727 | 170 | 175 | ||
728 | 171 | 176 | ||
729 | @@ -223,8 +228,9 @@ | |||
730 | 223 | class TestConnectionManager(Base): | 228 | class TestConnectionManager(Base): |
731 | 224 | """Test the "internal network" transitions.""" | 229 | """Test the "internal network" transitions.""" |
732 | 225 | 230 | ||
733 | 231 | @defer.inlineCallbacks | ||
734 | 226 | def setUp(self): | 232 | def setUp(self): |
736 | 227 | Base.setUp(self) | 233 | yield super(TestConnectionManager, self).setUp() |
737 | 228 | 234 | ||
738 | 229 | # put SM on some state that does not generate further | 235 | # put SM on some state that does not generate further |
739 | 230 | # transition-related efforts for this CM | 236 | # transition-related efforts for this CM |
740 | @@ -341,8 +347,9 @@ | |||
741 | 341 | class TestConnectionManagerTimings(Base): | 347 | class TestConnectionManagerTimings(Base): |
742 | 342 | """Times handled by ConnectionManager.""" | 348 | """Times handled by ConnectionManager.""" |
743 | 343 | 349 | ||
744 | 350 | @defer.inlineCallbacks | ||
745 | 344 | def setUp(self): | 351 | def setUp(self): |
747 | 345 | Base.setUp(self) | 352 | yield super(TestConnectionManagerTimings, self).setUp() |
748 | 346 | 353 | ||
749 | 347 | # set timeout values to really low, to make tests run quicker | 354 | # set timeout values to really low, to make tests run quicker |
750 | 348 | self.sm.connection.handshake_timeout = 0 | 355 | self.sm.connection.handshake_timeout = 0 |
751 | @@ -843,8 +850,10 @@ | |||
752 | 843 | class TestStateManagerPassToNetworkManager(Base): | 850 | class TestStateManagerPassToNetworkManager(Base): |
753 | 844 | """All network events should go to NetworkManager.""" | 851 | """All network events should go to NetworkManager.""" |
754 | 845 | 852 | ||
755 | 853 | @defer.inlineCallbacks | ||
756 | 846 | def setUp(self): | 854 | def setUp(self): |
758 | 847 | Base.setUp(self) | 855 | yield super(TestStateManagerPassToNetworkManager, |
759 | 856 | self).setUp() | ||
760 | 848 | 857 | ||
761 | 849 | # put a function in the middle to log calls | 858 | # put a function in the middle to log calls |
762 | 850 | self.called_events = [] | 859 | self.called_events = [] |
763 | @@ -893,8 +902,10 @@ | |||
764 | 893 | class TestStateManagerPassToQueueManager(Base): | 902 | class TestStateManagerPassToQueueManager(Base): |
765 | 894 | """All queue events should go to QueueManager.""" | 903 | """All queue events should go to QueueManager.""" |
766 | 895 | 904 | ||
767 | 905 | @defer.inlineCallbacks | ||
768 | 896 | def setUp(self): | 906 | def setUp(self): |
770 | 897 | Base.setUp(self) | 907 | yield super(TestStateManagerPassToQueueManager, |
771 | 908 | self).setUp() | ||
772 | 898 | 909 | ||
773 | 899 | # put a function in the middle to log calls | 910 | # put a function in the middle to log calls |
774 | 900 | self.called_events = [] | 911 | self.called_events = [] |
775 | 901 | 912 | ||
776 | === modified file 'tests/syncdaemon/test_status_listener.py' | |||
777 | --- tests/syncdaemon/test_status_listener.py 2011-08-05 15:50:52 +0000 | |||
778 | +++ tests/syncdaemon/test_status_listener.py 2011-11-07 18:03:24 +0000 | |||
779 | @@ -96,9 +96,10 @@ | |||
780 | 96 | class StatusListenerTestCase(FakeMainTestCase): | 96 | class StatusListenerTestCase(FakeMainTestCase): |
781 | 97 | """Tests for StatusListener.""" | 97 | """Tests for StatusListener.""" |
782 | 98 | 98 | ||
783 | 99 | @defer.inlineCallbacks | ||
784 | 99 | def setUp(self): | 100 | def setUp(self): |
785 | 100 | """Initialize this instance.""" | 101 | """Initialize this instance.""" |
787 | 101 | super(StatusListenerTestCase, self).setUp() | 102 | yield super(StatusListenerTestCase, self).setUp() |
788 | 102 | self.status_frontend = FakeStatusFrontend() | 103 | self.status_frontend = FakeStatusFrontend() |
789 | 103 | self.listener = status_listener.StatusListener(self.fs, self.vm, | 104 | self.listener = status_listener.StatusListener(self.fs, self.vm, |
790 | 104 | self.status_frontend) | 105 | self.status_frontend) |
791 | 105 | 106 | ||
792 | === modified file 'ubuntuone/syncdaemon/action_queue.py' | |||
793 | --- ubuntuone/syncdaemon/action_queue.py 2011-09-08 21:41:00 +0000 | |||
794 | +++ ubuntuone/syncdaemon/action_queue.py 2011-11-07 18:03:24 +0000 | |||
795 | @@ -37,7 +37,7 @@ | |||
796 | 37 | import zlib | 37 | import zlib |
797 | 38 | 38 | ||
798 | 39 | from collections import deque, defaultdict | 39 | from collections import deque, defaultdict |
800 | 40 | from functools import wraps, partial | 40 | from functools import partial |
801 | 41 | from urllib import urlencode | 41 | from urllib import urlencode |
802 | 42 | from urllib2 import urlopen, Request, HTTPError | 42 | from urllib2 import urlopen, Request, HTTPError |
803 | 43 | from urlparse import urljoin | 43 | from urlparse import urljoin |
804 | @@ -72,18 +72,7 @@ | |||
805 | 72 | EREGEX = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$" | 72 | EREGEX = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$" |
806 | 73 | 73 | ||
807 | 74 | # progress threshold to emit a download/upload progress event: 64Kb | 74 | # progress threshold to emit a download/upload progress event: 64Kb |
820 | 75 | TRANSFER_PROGRESS_THRESHOLD = 64*1024*1024 | 75 | TRANSFER_PROGRESS_THRESHOLD = 64 * 1024 * 1024 |
809 | 76 | |||
810 | 77 | def passit(func): | ||
811 | 78 | """Pass the value on for the next deferred, while calling func with it.""" | ||
812 | 79 | |||
813 | 80 | @wraps(func) | ||
814 | 81 | def wrapper(a): | ||
815 | 82 | """Do it.""" | ||
816 | 83 | func(a) | ||
817 | 84 | return a | ||
818 | 85 | |||
819 | 86 | return wrapper | ||
821 | 87 | 76 | ||
822 | 88 | 77 | ||
823 | 89 | class DeferredInterrupted(Exception): | 78 | class DeferredInterrupted(Exception): |
824 | @@ -116,7 +105,6 @@ | |||
825 | 116 | self.errback(DeferredInterrupted()) | 105 | self.errback(DeferredInterrupted()) |
826 | 117 | 106 | ||
827 | 118 | 107 | ||
828 | 119 | |||
829 | 120 | class PathLockingTree(object): | 108 | class PathLockingTree(object): |
830 | 121 | """Tree that stores deferreds in the nodes.""" | 109 | """Tree that stores deferreds in the nodes.""" |
831 | 122 | 110 | ||
832 | @@ -214,7 +202,6 @@ | |||
833 | 214 | node, element = branch.pop() | 202 | node, element = branch.pop() |
834 | 215 | del node['children_nodes'][element] | 203 | del node['children_nodes'][element] |
835 | 216 | 204 | ||
836 | 217 | |||
837 | 218 | # finally, log and release the deferred | 205 | # finally, log and release the deferred |
838 | 219 | logger.debug("pathlock releasing %s; remaining: %d", elements, | 206 | logger.debug("pathlock releasing %s; remaining: %d", elements, |
839 | 220 | self.count) | 207 | self.count) |
840 | @@ -250,8 +237,8 @@ | |||
841 | 250 | return ('start - processMessage: id: %s, type: %s', | 237 | return ('start - processMessage: id: %s, type: %s', |
842 | 251 | message.id, message.type) | 238 | message.id, message.type) |
843 | 252 | elif message.type == protocol_pb2.Message.PUT_CONTENT: | 239 | elif message.type == protocol_pb2.Message.PUT_CONTENT: |
846 | 253 | lines = [ line for line in str(message).split("\n") | 240 | lines = [line for line in str(message).split("\n") |
847 | 254 | if not line.strip().startswith("magic_hash:") ] | 241 | if not line.strip().startswith("magic_hash:")] |
848 | 255 | return ('start - processMessage: %s', | 242 | return ('start - processMessage: %s', |
849 | 256 | " ".join(lines)) | 243 | " ".join(lines)) |
850 | 257 | else: | 244 | else: |
851 | @@ -461,12 +448,8 @@ | |||
852 | 461 | magic_hasher.update(data) | 448 | magic_hasher.update(data) |
853 | 462 | upload.deflated_size = f.tell() | 449 | upload.deflated_size = f.tell() |
854 | 463 | 450 | ||
855 | 464 | # keep the file open, but reset its position | ||
856 | 465 | # to zero, ready to be read later | ||
857 | 466 | f.seek(0) | ||
858 | 467 | |||
859 | 468 | upload.magic_hash = magic_hasher.content_hash() | 451 | upload.magic_hash = magic_hasher.content_hash() |
861 | 469 | except Exception, e: # pylint: disable-msg=W0703 | 452 | except Exception, e: # pylint: disable-msg=W0703 |
862 | 470 | failed = True | 453 | failed = True |
863 | 471 | reactor.callFromThread(deferred.errback, e) | 454 | reactor.callFromThread(deferred.errback, e) |
864 | 472 | finally: | 455 | finally: |
865 | @@ -705,10 +688,10 @@ | |||
866 | 705 | self.token = None | 688 | self.token = None |
867 | 706 | self.consumer = None | 689 | self.consumer = None |
868 | 707 | 690 | ||
870 | 708 | self.client = None # an instance of self.protocol | 691 | self.client = None # an instance of self.protocol |
871 | 709 | 692 | ||
872 | 710 | # is a twisted.internet.tcp/ssl.Connector instance | 693 | # is a twisted.internet.tcp/ssl.Connector instance |
874 | 711 | self.connector = None # created on reactor.connectTCP/SSL | 694 | self.connector = None # created on reactor.connectTCP/SSL |
875 | 712 | # we need to track down if a connection is in progress | 695 | # we need to track down if a connection is in progress |
876 | 713 | # to avoid double connections | 696 | # to avoid double connections |
877 | 714 | self.connect_in_progress = False | 697 | self.connect_in_progress = False |
878 | @@ -1029,8 +1012,8 @@ | |||
879 | 1029 | @defer.inlineCallbacks | 1012 | @defer.inlineCallbacks |
880 | 1030 | def authenticate(self): | 1013 | def authenticate(self): |
881 | 1031 | """Authenticate against the server using stored credentials.""" | 1014 | """Authenticate against the server using stored credentials.""" |
884 | 1032 | metadata = {'version':clientdefs.VERSION, | 1015 | metadata = {'version': clientdefs.VERSION, |
885 | 1033 | 'platform':platform} | 1016 | 'platform': platform} |
886 | 1034 | authenticate_d = self._send_request_and_handle_errors( | 1017 | authenticate_d = self._send_request_and_handle_errors( |
887 | 1035 | request=self.client.oauth_authenticate, | 1018 | request=self.client.oauth_authenticate, |
888 | 1036 | request_error=protocol_errors.AuthenticationFailedError, | 1019 | request_error=protocol_errors.AuthenticationFailedError, |
889 | @@ -2078,7 +2061,6 @@ | |||
890 | 2078 | self.log = mklog(logger, 'GetDeltaFromScratch', self.volume_id, None) | 2061 | self.log = mklog(logger, 'GetDeltaFromScratch', self.volume_id, None) |
891 | 2079 | 2062 | ||
892 | 2080 | 2063 | ||
893 | 2081 | |||
894 | 2082 | class ChangePublicAccess(ActionQueueCommand): | 2064 | class ChangePublicAccess(ActionQueueCommand): |
895 | 2083 | """Change the public access of a file.""" | 2065 | """Change the public access of a file.""" |
896 | 2084 | 2066 | ||
897 | @@ -2498,6 +2480,11 @@ | |||
898 | 2498 | 2480 | ||
899 | 2499 | def finish(self): | 2481 | def finish(self): |
900 | 2500 | """Release the semaphore if already acquired.""" | 2482 | """Release the semaphore if already acquired.""" |
901 | 2483 | if self.tempfile is not None: | ||
902 | 2484 | # clean the temporary file | ||
903 | 2485 | self.tempfile.close() | ||
904 | 2486 | remove_file(self.tempfile.name) | ||
905 | 2487 | |||
906 | 2501 | if self.tx_semaphore is not None: | 2488 | if self.tx_semaphore is not None: |
907 | 2502 | self.tx_semaphore = self.tx_semaphore.release() | 2489 | self.tx_semaphore = self.tx_semaphore.release() |
908 | 2503 | self.log.debug('semaphore released') | 2490 | self.log.debug('semaphore released') |
909 | @@ -2509,7 +2496,7 @@ | |||
910 | 2509 | share_id=self.share_id, | 2496 | share_id=self.share_id, |
911 | 2510 | node_id=self.node_id, | 2497 | node_id=self.node_id, |
912 | 2511 | hash=self.hash) | 2498 | hash=self.hash) |
914 | 2512 | 2499 | self.tempfile.seek(0) | |
915 | 2513 | f = UploadProgressWrapper(self.tempfile, self) | 2500 | f = UploadProgressWrapper(self.tempfile, self) |
916 | 2514 | 2501 | ||
917 | 2515 | # access here the magic hash value, don't log anywhere, and | 2502 | # access here the magic hash value, don't log anywhere, and |
918 | @@ -2521,9 +2508,7 @@ | |||
919 | 2521 | upload_id=self.upload_id, upload_id_cb=self._upload_id_cb, | 2508 | upload_id=self.upload_id, upload_id_cb=self._upload_id_cb, |
920 | 2522 | magic_hash=magic_hash) | 2509 | magic_hash=magic_hash) |
921 | 2523 | self.upload_req = req | 2510 | self.upload_req = req |
925 | 2524 | d = req.deferred | 2511 | return req.deferred |
923 | 2525 | d.addBoth(passit(lambda _: self.tempfile.close())) | ||
924 | 2526 | return d | ||
926 | 2527 | 2512 | ||
927 | 2528 | def _upload_id_cb(self, upload_id): | 2513 | def _upload_id_cb(self, upload_id): |
928 | 2529 | """Handle the received upload_id, save it in the metadata.""" | 2514 | """Handle the received upload_id, save it in the metadata.""" |
929 | @@ -2545,9 +2530,6 @@ | |||
930 | 2545 | 2530 | ||
931 | 2546 | def handle_success(self, request): | 2531 | def handle_success(self, request): |
932 | 2547 | """It worked! Push the event.""" | 2532 | """It worked! Push the event.""" |
933 | 2548 | # remove the temporary file | ||
934 | 2549 | remove_file(self.tempfile.name) | ||
935 | 2550 | |||
936 | 2551 | # send the event | 2533 | # send the event |
937 | 2552 | d = dict(share_id=self.share_id, node_id=self.node_id, hash=self.hash, | 2534 | d = dict(share_id=self.share_id, node_id=self.node_id, hash=self.hash, |
938 | 2553 | new_generation=request.new_generation) | 2535 | new_generation=request.new_generation) |
939 | @@ -2563,7 +2545,6 @@ | |||
940 | 2563 | 2545 | ||
941 | 2564 | def handle_failure(self, failure): | 2546 | def handle_failure(self, failure): |
942 | 2565 | """It didn't work! Push the event.""" | 2547 | """It didn't work! Push the event.""" |
943 | 2566 | remove_file(self.tempfile.name) | ||
944 | 2567 | self.action_queue.event_queue.push('AQ_UPLOAD_ERROR', | 2548 | self.action_queue.event_queue.push('AQ_UPLOAD_ERROR', |
945 | 2568 | error=failure.getErrorMessage(), | 2549 | error=failure.getErrorMessage(), |
946 | 2569 | share_id=self.share_id, | 2550 | share_id=self.share_id, |
Tested and passed using test case in bug #872924