Merge lp:~thisfred/ubuntuone-client/fix-progressbar-tests-on-windows into lp:ubuntuone-client

Proposed by Eric Casteleijn
Status: Merged
Approved by: dobey
Approved revision: 1023
Merged at revision: 1022
Proposed branch: lp:~thisfred/ubuntuone-client/fix-progressbar-tests-on-windows
Merge into: lp:ubuntuone-client
Diff against target: 224 lines (+61/-25)
4 files modified
tests/status/test_aggregator.py (+30/-9)
tests/syncdaemon/test_status_listener.py (+6/-4)
ubuntuone/status/aggregator.py (+21/-10)
ubuntuone/syncdaemon/status_listener.py (+4/-2)
To merge this branch: bzr merge lp:~thisfred/ubuntuone-client/fix-progressbar-tests-on-windows
Reviewer Review Type Date Requested Status
dobey (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+65838@code.launchpad.net

Commit message

* Progress aggregation now correctly handles None when it is reported as deflated_size for an upload or download (LP: #801736)

Description of the change

* Progress aggregation now correctly handles None when it is reported as deflated_size for an upload or download (LP: #801736)

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/status/test_aggregator.py'
2--- tests/status/test_aggregator.py 2011-06-20 14:22:35 +0000
3+++ tests/status/test_aggregator.py 2011-06-24 21:41:23 +0000
4@@ -737,9 +737,10 @@
5 self.files_uploading.remove(command)
6 self.queued_commands.discard(command)
7
8- def progress_made(self, share_id, node_id, n_bytes_written):
9+ def progress_made(self, share_id, node_id, n_bytes_written, deflated_size):
10 """Progress made on up- or download."""
11- self.progress_events.append((share_id, node_id, n_bytes_written))
12+ self.progress_events.append(
13+ (share_id, node_id, n_bytes_written, deflated_size))
14
15 def connection_made(self):
16 """The client made the connection to the server."""
17@@ -807,6 +808,15 @@
18 qc = self.status_frontend.aggregator.queued_commands
19 self.assertIn(fake_command, qc)
20
21+ def test_download_started_with_no_deflated_size(self):
22+ """A download of unknown size was added to the queue."""
23+ self.patch(status_listener.action_queue, "Download", FakeCommand)
24+ fake_command = FakeCommand()
25+ fake_command.deflated_size = None
26+ self.listener.handle_SYS_QUEUE_ADDED(fake_command)
27+ qc = self.status_frontend.aggregator.queued_commands
28+ self.assertIn(fake_command, qc)
29+
30 def test_download_finished(self):
31 """A download was removed from the queue."""
32 self.patch(status_listener.action_queue, "Download", FakeCommand)
33@@ -817,15 +827,24 @@
34 self.assertNotIn(fake_command, qc)
35
36 def test_upload_started(self):
37- """A upload was added to the queue."""
38- self.patch(status_listener.action_queue, "Upload", FakeCommand)
39- fake_command = FakeCommand()
40+ """An upload was added to the queue."""
41+ self.patch(status_listener.action_queue, "Upload", FakeCommand)
42+ fake_command = FakeCommand()
43+ self.listener.handle_SYS_QUEUE_ADDED(fake_command)
44+ qc = self.status_frontend.aggregator.queued_commands
45+ self.assertIn(fake_command, qc)
46+
47+ def test_upload_started_with_no_deflated_size(self):
48+ """An upload of unknown size was added to the queue."""
49+ self.patch(status_listener.action_queue, "Upload", FakeCommand)
50+ fake_command = FakeCommand()
51+ fake_command.deflated_size = None
52 self.listener.handle_SYS_QUEUE_ADDED(fake_command)
53 qc = self.status_frontend.aggregator.queued_commands
54 self.assertIn(fake_command, qc)
55
56 def test_upload_finished(self):
57- """A upload was removed from the queue."""
58+ """An upload was removed from the queue."""
59 self.patch(status_listener.action_queue, "Upload", FakeCommand)
60 fake_command = FakeCommand()
61 self.listener.handle_SYS_QUEUE_ADDED(fake_command)
62@@ -843,7 +862,7 @@
63 share_id, node_id, n_bytes_written, deflated_size)
64 pe = self.status_frontend.aggregator.progress_events
65 self.assertEqual(
66- [(share_id, node_id, n_bytes_written)], pe,
67+ [(share_id, node_id, n_bytes_written, deflated_size)], pe,
68 "progress_made was not called (exactly once) on aggregator.")
69
70 def test_progress_made_on_download(self):
71@@ -856,7 +875,7 @@
72 share_id, node_id, n_bytes_written, deflated_size)
73 pe = self.status_frontend.aggregator.progress_events
74 self.assertEqual(
75- [(share_id, node_id, n_bytes_written)], pe,
76+ [(share_id, node_id, n_bytes_written, deflated_size)], pe,
77 "progress_made was not called (exactly once) on aggregator.")
78
79 def test_queue_done(self):
80@@ -1305,7 +1324,9 @@
81 share_id = 'fake_share'
82 node_id = 'fake_node'
83 n_bytes_written = 200
84- self.aggregator.progress_made(share_id, node_id, n_bytes_written)
85+ deflated_size = 100000
86+ self.aggregator.progress_made(
87+ share_id, node_id, n_bytes_written, deflated_size)
88 self.assertEqual(
89 {(share_id, node_id): (n_bytes_written)},
90 self.aggregator.progress)
91
92=== modified file 'tests/syncdaemon/test_status_listener.py'
93--- tests/syncdaemon/test_status_listener.py 2011-06-24 13:42:03 +0000
94+++ tests/syncdaemon/test_status_listener.py 2011-06-24 21:41:23 +0000
95@@ -194,7 +194,7 @@
96 """Upload/Download Progress events are passed to the status object."""
97
98 @defer.inlineCallbacks
99- def test_download_added_is_forwarded(self):
100+ def test_upload_progress_is_forwarded(self):
101 """A download progress event is forwarded."""
102 share_id = "share"
103 node_id = "node_id"
104@@ -207,11 +207,12 @@
105 n_bytes_written=n_bytes_written, deflated_size=deflated_size)
106 yield d
107 call = (
108- "progress_made", (share_id, node_id, n_bytes_written), {})
109+ "progress_made",
110+ (share_id, node_id, n_bytes_written, deflated_size), {})
111 self.assertIn(call, self.status_frontend.call_log)
112
113 @defer.inlineCallbacks
114- def test_upload_added_is_forwarded(self):
115+ def test_download_progress_is_forwarded(self):
116 """An upload progress event is forwarded."""
117 share_id = "share"
118 node_id = "node_id"
119@@ -224,7 +225,8 @@
120 n_bytes_written=n_bytes_written, deflated_size=deflated_size)
121 yield d
122 call = (
123- "progress_made", (share_id, node_id, n_bytes_written), {})
124+ "progress_made",
125+ (share_id, node_id, n_bytes_written, deflated_size), {})
126 self.assertIn(call, self.status_frontend.call_log)
127
128
129
130=== modified file 'ubuntuone/status/aggregator.py'
131--- ubuntuone/status/aggregator.py 2011-06-20 14:22:35 +0000
132+++ ubuntuone/status/aggregator.py 2011-06-24 21:41:23 +0000
133@@ -718,7 +718,9 @@
134 self.queue_done_timer.cleanup()
135 self.queue_done_timer = None
136 self.files_downloading.append(command)
137- self.to_do[(command.share_id, command.node_id)] = command.deflated_size
138+ if command.deflated_size is not None:
139+ self.to_do[
140+ (command.share_id, command.node_id)] = command.deflated_size
141 # pylint: disable=W0201
142 if not self.downloading_filename:
143 self.downloading_filename = self.files_downloading[0].path.split(
144@@ -735,8 +737,9 @@
145 if command in self.files_downloading:
146 self.files_downloading.remove(command)
147 self.download_done += 1
148- self.progress[
149- (command.share_id, command.node_id)] = command.deflated_size
150+ if command.deflated_size is not None:
151+ self.progress[
152+ (command.share_id, command.node_id)] = command.deflated_size
153 logger.debug("unqueueing command: %s", command.__class__.__name__)
154 self.update_progressbar()
155
156@@ -746,7 +749,9 @@
157 self.queue_done_timer.cleanup()
158 self.queue_done_timer = None
159 self.files_uploading.append(command)
160- self.to_do[(command.share_id, command.node_id)] = command.deflated_size
161+ if command.deflated_size is not None:
162+ self.to_do[
163+ (command.share_id, command.node_id)] = command.deflated_size
164 # pylint: disable=W0201
165 if not self.uploading_filename:
166 self.uploading_filename = self.files_uploading[0].path.split(
167@@ -763,14 +768,19 @@
168 if command in self.files_uploading:
169 self.files_uploading.remove(command)
170 self.upload_done += 1
171- self.progress[
172- (command.share_id, command.node_id)] = command.deflated_size
173+ if command.deflated_size is not None:
174+ self.progress[
175+ (command.share_id, command.node_id)] = command.deflated_size
176 logger.debug("unqueueing command: %s", command.__class__.__name__)
177 self.update_progressbar()
178
179- def progress_made(self, share_id, node_id, n_bytes_written):
180+ def progress_made(self, share_id, node_id, n_bytes_written, deflated_size):
181 """Progress made on up- or download."""
182- self.progress[(share_id, node_id)] = n_bytes_written
183+ if n_bytes_written is not None:
184+ # if we haven't gotten the total size yet, set it now
185+ if deflated_size and (share_id, node_id) not in self.to_do:
186+ self.to_do[(share_id, node_id)] = deflated_size
187+ self.progress[(share_id, node_id)] = n_bytes_written
188 self.update_progressbar()
189
190 def connection_lost(self):
191@@ -820,9 +830,10 @@
192 """A file upload was unqueued."""
193 self.aggregator.upload_finished(command)
194
195- def progress_made(self, share_id, node_id, n_bytes_written):
196+ def progress_made(self, share_id, node_id, n_bytes_written, deflated_size):
197 """Progress made on up- or download."""
198- self.aggregator.progress_made(share_id, node_id, n_bytes_written)
199+ self.aggregator.progress_made(
200+ share_id, node_id, n_bytes_written, deflated_size)
201
202 def queue_done(self):
203 """The queue is empty."""
204
205=== modified file 'ubuntuone/syncdaemon/status_listener.py'
206--- ubuntuone/syncdaemon/status_listener.py 2011-06-20 14:22:35 +0000
207+++ ubuntuone/syncdaemon/status_listener.py 2011-06-24 21:41:23 +0000
208@@ -77,12 +77,14 @@
209 def handle_AQ_UPLOAD_FILE_PROGRESS(self, share_id, node_id,
210 n_bytes_written, deflated_size):
211 """Progress has been made on an upload."""
212- self.status_frontend.progress_made(share_id, node_id, n_bytes_written)
213+ self.status_frontend.progress_made(
214+ share_id, node_id, n_bytes_written, deflated_size)
215
216 def handle_AQ_DOWNLOAD_FILE_PROGRESS(self, share_id, node_id,
217 n_bytes_written, deflated_size):
218 """Progress has been made on an upload."""
219- self.status_frontend.progress_made(share_id, node_id, n_bytes_written)
220+ self.status_frontend.progress_made(
221+ share_id, node_id, n_bytes_written, deflated_size)
222 # pylint: enable=W0613
223
224 def handle_SYS_QUEUE_ADDED(self, command):

Subscribers

People subscribed via source and target branches