Merge lp:~mikemc/ubuntuone-client/no-multi-add-recents-fix-1069953 into lp:ubuntuone-client

Proposed by Mike McCracken
Status: Merged
Approved by: dobey
Approved revision: 1348
Merged at revision: 1355
Proposed branch: lp:~mikemc/ubuntuone-client/no-multi-add-recents-fix-1069953
Merge into: lp:ubuntuone-client
Prerequisite: lp:~mikemc/ubuntuone-client/add-downloads-to-menudata
Diff against target: 69 lines (+32/-2)
2 files modified
tests/status/test_aggregator.py (+28/-2)
ubuntuone/status/aggregator.py (+4/-0)
To merge this branch: bzr merge lp:~mikemc/ubuntuone-client/no-multi-add-recents-fix-1069953
Reviewer Review Type Date Requested Status
dobey (community) Approve
Diego Sarmentero (community) Approve
Review via email: mp+131233@code.launchpad.net

Commit message

- Avoid adding the same file to the recent transfers list twice, just reorder it. (LP: #1069953)

Description of the change

- Avoid adding the same file to the recent transfers list twice, just reorder it. (LP: #1069953)

Updated tests are in tests/status/

To post a comment you must log in.
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

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 2012-10-24 16:12:31 +0000
3+++ tests/status/test_aggregator.py 2012-10-24 16:12:31 +0000
4@@ -1529,15 +1529,41 @@
5 def test_max_recent_files(self):
6 """Check that the queue doesn't exceed the 5 items."""
7 for i in range(10):
8- fc = FakeUploadCommand()
9+ fc = FakeUploadCommand(str(i))
10 self.status_frontend.upload_started(fc)
11 self.status_frontend.upload_finished(fc)
12 for i in range(10):
13- fc = FakeDownloadCommand()
14+ fc = FakeDownloadCommand(str(i))
15 self.status_frontend.download_started(fc)
16 self.status_frontend.download_finished(fc)
17 self.assertEqual(len(self.aggregator.recent_transfers), 5)
18
19+ def test_recent_transfers_is_unique(self):
20+ """Check that a given path is not repeated in recent transfers."""
21+ fc = FakeDownloadCommand('hi')
22+ self.status_frontend.download_started(fc)
23+ self.status_frontend.download_finished(fc)
24+ fc = FakeDownloadCommand('hi')
25+ self.status_frontend.download_started(fc)
26+ self.status_frontend.download_finished(fc)
27+ self.assertEqual(len(self.aggregator.recent_transfers), 1)
28+
29+ def test_recent_transfers_reorders(self):
30+ """Check that if a transfer is repeated we put it back at the end."""
31+ fc = FakeDownloadCommand('hi')
32+ self.status_frontend.download_started(fc)
33+ self.status_frontend.download_finished(fc)
34+ fc = FakeDownloadCommand('howdy')
35+ self.status_frontend.download_started(fc)
36+ self.status_frontend.download_finished(fc)
37+ fc = FakeUploadCommand('hi')
38+ self.status_frontend.upload_started(fc)
39+ self.status_frontend.upload_finished(fc)
40+
41+ self.assertEqual(len(self.aggregator.recent_transfers), 2)
42+ self.assertEqual(['howdy', 'hi'],
43+ list(self.aggregator.recent_transfers))
44+
45 def test_progress_made(self):
46 """Progress on up and downloads is tracked."""
47 share_id = 'fake_share'
48
49=== modified file 'ubuntuone/status/aggregator.py'
50--- ubuntuone/status/aggregator.py 2012-10-24 16:12:31 +0000
51+++ ubuntuone/status/aggregator.py 2012-10-24 16:12:31 +0000
52@@ -754,6 +754,8 @@
53 if command.deflated_size is not None:
54 self.progress[
55 (command.share_id, command.node_id)] = command.deflated_size
56+ if command.path in self.recent_transfers:
57+ self.recent_transfers.remove(command.path)
58 self.recent_transfers.append(command.path)
59 logger.debug("unqueueing command: %s", command.__class__.__name__)
60 self.update_progressbar()
61@@ -786,6 +788,8 @@
62 if command.deflated_size is not None:
63 self.progress[
64 (command.share_id, command.node_id)] = command.deflated_size
65+ if command.path in self.recent_transfers:
66+ self.recent_transfers.remove(command.path)
67 self.recent_transfers.append(command.path)
68 logger.debug("unqueueing command: %s", command.__class__.__name__)
69 self.update_progressbar()

Subscribers

People subscribed via source and target branches