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
=== modified file 'tests/status/test_aggregator.py'
--- tests/status/test_aggregator.py 2012-10-24 16:12:31 +0000
+++ tests/status/test_aggregator.py 2012-10-24 16:12:31 +0000
@@ -1529,15 +1529,41 @@
1529 def test_max_recent_files(self):1529 def test_max_recent_files(self):
1530 """Check that the queue doesn't exceed the 5 items."""1530 """Check that the queue doesn't exceed the 5 items."""
1531 for i in range(10):1531 for i in range(10):
1532 fc = FakeUploadCommand()1532 fc = FakeUploadCommand(str(i))
1533 self.status_frontend.upload_started(fc)1533 self.status_frontend.upload_started(fc)
1534 self.status_frontend.upload_finished(fc)1534 self.status_frontend.upload_finished(fc)
1535 for i in range(10):1535 for i in range(10):
1536 fc = FakeDownloadCommand()1536 fc = FakeDownloadCommand(str(i))
1537 self.status_frontend.download_started(fc)1537 self.status_frontend.download_started(fc)
1538 self.status_frontend.download_finished(fc)1538 self.status_frontend.download_finished(fc)
1539 self.assertEqual(len(self.aggregator.recent_transfers), 5)1539 self.assertEqual(len(self.aggregator.recent_transfers), 5)
15401540
1541 def test_recent_transfers_is_unique(self):
1542 """Check that a given path is not repeated in recent transfers."""
1543 fc = FakeDownloadCommand('hi')
1544 self.status_frontend.download_started(fc)
1545 self.status_frontend.download_finished(fc)
1546 fc = FakeDownloadCommand('hi')
1547 self.status_frontend.download_started(fc)
1548 self.status_frontend.download_finished(fc)
1549 self.assertEqual(len(self.aggregator.recent_transfers), 1)
1550
1551 def test_recent_transfers_reorders(self):
1552 """Check that if a transfer is repeated we put it back at the end."""
1553 fc = FakeDownloadCommand('hi')
1554 self.status_frontend.download_started(fc)
1555 self.status_frontend.download_finished(fc)
1556 fc = FakeDownloadCommand('howdy')
1557 self.status_frontend.download_started(fc)
1558 self.status_frontend.download_finished(fc)
1559 fc = FakeUploadCommand('hi')
1560 self.status_frontend.upload_started(fc)
1561 self.status_frontend.upload_finished(fc)
1562
1563 self.assertEqual(len(self.aggregator.recent_transfers), 2)
1564 self.assertEqual(['howdy', 'hi'],
1565 list(self.aggregator.recent_transfers))
1566
1541 def test_progress_made(self):1567 def test_progress_made(self):
1542 """Progress on up and downloads is tracked."""1568 """Progress on up and downloads is tracked."""
1543 share_id = 'fake_share'1569 share_id = 'fake_share'
15441570
=== modified file 'ubuntuone/status/aggregator.py'
--- ubuntuone/status/aggregator.py 2012-10-24 16:12:31 +0000
+++ ubuntuone/status/aggregator.py 2012-10-24 16:12:31 +0000
@@ -754,6 +754,8 @@
754 if command.deflated_size is not None:754 if command.deflated_size is not None:
755 self.progress[755 self.progress[
756 (command.share_id, command.node_id)] = command.deflated_size756 (command.share_id, command.node_id)] = command.deflated_size
757 if command.path in self.recent_transfers:
758 self.recent_transfers.remove(command.path)
757 self.recent_transfers.append(command.path)759 self.recent_transfers.append(command.path)
758 logger.debug("unqueueing command: %s", command.__class__.__name__)760 logger.debug("unqueueing command: %s", command.__class__.__name__)
759 self.update_progressbar()761 self.update_progressbar()
@@ -786,6 +788,8 @@
786 if command.deflated_size is not None:788 if command.deflated_size is not None:
787 self.progress[789 self.progress[
788 (command.share_id, command.node_id)] = command.deflated_size790 (command.share_id, command.node_id)] = command.deflated_size
791 if command.path in self.recent_transfers:
792 self.recent_transfers.remove(command.path)
789 self.recent_transfers.append(command.path)793 self.recent_transfers.append(command.path)
790 logger.debug("unqueueing command: %s", command.__class__.__name__)794 logger.debug("unqueueing command: %s", command.__class__.__name__)
791 self.update_progressbar()795 self.update_progressbar()

Subscribers

People subscribed via source and target branches