Merge lp:~diegosarmentero/ubuntuone-control-panel/transfers into lp:ubuntuone-control-panel

Proposed by Diego Sarmentero on 2012-08-16
Status: Merged
Approved by: Diego Sarmentero on 2012-08-20
Approved revision: 350
Merged at revision: 344
Proposed branch: lp:~diegosarmentero/ubuntuone-control-panel/transfers
Merge into: lp:ubuntuone-control-panel
Diff against target: 531 lines (+371/-3)
4 files modified
ubuntuone/controlpanel/gui/__init__.py (+5/-0)
ubuntuone/controlpanel/gui/qt/systray.py (+121/-1)
ubuntuone/controlpanel/gui/qt/tests/__init__.py (+12/-1)
ubuntuone/controlpanel/gui/qt/tests/test_systray.py (+233/-1)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntuone-control-panel/transfers
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve on 2012-08-20
Roberto Alsina (community) 2012-08-16 Approve on 2012-08-16
Review via email: mp+119932@code.launchpad.net

Commit Message

- Show current and recent transfers on the transfers menu (LP: #1034542).

Description of the Change

You will need this branch:
lp:~diegosarmentero/ubuntuone-client/menu-progress

to test it IRL on windows.

To post a comment you must log in.
347. By Diego Sarmentero on 2012-08-16

fixing tests

348. By Diego Sarmentero on 2012-08-16

fixed import

349. By Diego Sarmentero on 2012-08-16

improves in progress actoin

Roberto Alsina (ralsina) wrote :

Looks great!

review: Approve
Manuel de la Peña (mandel) wrote :

Maybe an assert for the following is better than just a simple comment:

127 + # This is never executed on Ubuntu

and

134 + # This is never executed on Ubuntu

If not an assert a log call.

Also, why do we do the following:

340 + self.patch(systray.TransfersMenu, "startTimer", lambda s, x: None)
341 + yield super(TransfersMenuTestCase, self).setUp()

Do we have to patch it before calling the super version? Can we add a comment with the reason.

The definition of a call like:

384 + def fake_sync_menu():
385 + """Fake backend sync_menu."""
386 + # Return copy of in_progress
387 + return {RECENTTRANSFERS: [], UPLOADING: in_progress[:]}

is done several times. We can do that in the setUp, for example like this:

self.recent_transfers = []
self.uploading = []

def fake_sync_menu():
    return return {RECENTTRANSFERS: self.recent_transfers, UPLOADING: self.uploading}

and just change the value of the vars according to the tests.

review: Needs Fixing
350. By Diego Sarmentero on 2012-08-20

Some improves in logs and tests

Diego Sarmentero (diegosarmentero) wrote :

> Maybe an assert for the following is better than just a simple comment:
>
> 127 + # This is never executed on Ubuntu
>
> and
>
> 134 + # This is never executed on Ubuntu
>
> If not an assert a log call.
>
> Also, why do we do the following:
>
> 340 + self.patch(systray.TransfersMenu, "startTimer", lambda s, x: None)
> 341 + yield super(TransfersMenuTestCase, self).setUp()
>
> Do we have to patch it before calling the super version? Can we add a comment
> with the reason.
>
> The definition of a call like:
>
> 384 + def fake_sync_menu():
> 385 + """Fake backend sync_menu."""
> 386 + # Return copy of in_progress
> 387 + return {RECENTTRANSFERS: [], UPLOADING: in_progress[:]}
>
> is done several times. We can do that in the setUp, for example like this:
>
> self.recent_transfers = []
> self.uploading = []
>
> def fake_sync_menu():
> return return {RECENTTRANSFERS: self.recent_transfers, UPLOADING:
> self.uploading}
>
> and just change the value of the vars according to the tests.

Done!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/controlpanel/gui/__init__.py'
2--- ubuntuone/controlpanel/gui/__init__.py 2012-08-08 18:36:45 +0000
3+++ ubuntuone/controlpanel/gui/__init__.py 2012-08-20 12:54:22 +0000
4@@ -42,6 +42,10 @@
5 SHARES_MIN_SIZE_FULL = 1048576
6 SUCCESS_COLOR = u'green'
7
8+# Sync Menu:
9+RECENTTRANSFERS = 'recent-transfers'
10+UPLOADING = 'uploading'
11+
12 ERROR_ICON = u'✘'
13 SYNCING_ICON = u'⇅'
14 IDLE_ICON = u'✔'
15@@ -179,6 +183,7 @@
16 GREETING = _('Hi %(user_display_name)s')
17 GO_TO_WEB = _('Go to the Website')
18 IN_PROGRESS = _('In Progress')
19+IN_PROGRESS_FILE = u'%s – %d%%'
20 INSTALL = _('Install')
21 INSTALL_PACKAGE = _('You need to install the package <i>%(package_name)s'
22 '</i> in order to enable more sync services.')
23
24=== modified file 'ubuntuone/controlpanel/gui/qt/systray.py'
25--- ubuntuone/controlpanel/gui/qt/systray.py 2012-08-13 17:06:15 +0000
26+++ ubuntuone/controlpanel/gui/qt/systray.py 2012-08-20 12:54:22 +0000
27@@ -15,6 +15,10 @@
28 # with this program. If not, see <http://www.gnu.org/licenses/>.
29 """System notification area icon."""
30
31+import os
32+import sys
33+from operator import itemgetter
34+
35 from PyQt4 import QtGui, QtCore
36 from twisted.internet.defer import inlineCallbacks
37 from ubuntuone.platform.tools import SyncDaemonTool
38@@ -28,10 +32,16 @@
39 GET_STORAGE_LINK,
40 GET_SUPPORT_LINK,
41 GO_TO_WEB,
42+ IN_PROGRESS,
43+ IN_PROGRESS_FILE,
44 LOADING,
45 OPEN_UBUNTU_ONE,
46 OPEN_UBUNTU_ONE_FOLDER,
47 PLEASE_WAIT,
48+ RECENT_TRANSFERS,
49+ RECENTTRANSFERS,
50+ TRANSFERS,
51+ UPLOADING,
52 )
53 from ubuntuone.controlpanel.gui.qt import (
54 FILE_SYNC_STATUS,
55@@ -42,6 +52,37 @@
56 logger = setup_logging('qt.systray')
57
58
59+class ProgressBarAction(QtGui.QWidgetAction):
60+
61+ """Menu action that display a progress bar for the uploads."""
62+
63+ def __init__(self, filename, percentage, parent=None):
64+ super(ProgressBarAction, self).__init__(parent)
65+ self._filename = os.path.basename(filename)
66+ self.widget = QtGui.QWidget(None)
67+ text = IN_PROGRESS_FILE % (self._filename, percentage)
68+ self.setText(text)
69+ self.label = QtGui.QLabel(text)
70+ self.progress = QtGui.QProgressBar()
71+ self.progress.setTextVisible(False)
72+ self.progress.setValue(percentage)
73+ self.progress.setFixedHeight(10)
74+ vbox = QtGui.QVBoxLayout()
75+ vbox.setContentsMargins(10, 5, 10, 5)
76+ vbox.addWidget(self.label)
77+ vbox.addWidget(self.progress)
78+ self.widget.setLayout(vbox)
79+
80+ self.setDefaultWidget(self.widget)
81+
82+ def set_value(self, progress):
83+ """Set the value of the progress bar."""
84+ text = IN_PROGRESS_FILE % (self._filename, progress)
85+ self.setText(text)
86+ self.label.setText(text)
87+ self.progress.setValue(progress)
88+
89+
90 class TrayIcon(QtGui.QSystemTrayIcon, cache.Cache):
91
92 """System notification icon."""
93@@ -74,7 +115,9 @@
94
95 # TODO: Shares
96
97- # TODO: Transfers
98+ # Transfers
99+ self.transfers = TransfersMenu(self)
100+ self.context_menu.addMenu(self.transfers)
101
102 self.get_more_storage = self.context_menu.addAction(GET_MORE_STORAGE)
103 self.get_help_online = self.context_menu.addAction(GET_HELP_ONLINE)
104@@ -192,3 +235,80 @@
105 # Maybe it was not running?
106 pass
107 self.close_callback()
108+
109+
110+class TransfersMenu(QtGui.QMenu):
111+
112+ """Menu that shows recent and current transfers."""
113+
114+ def __init__(self, parent):
115+ super(TransfersMenu, self).__init__(TRANSFERS)
116+ self._parent = parent
117+ self.uploading = {}
118+ self.previous_data = {}
119+
120+ if sys.platform not in ('win32', 'darwin'):
121+ self._timer_id = self.startTimer(1000)
122+
123+ # pylint: disable=C0103
124+
125+ def showEvent(self, event):
126+ """Executed when the transfers menu is shown."""
127+ logger.info('This is never executed on Ubuntu')
128+ super(TransfersMenu, self).showEvent(event)
129+ self.get_transfers_data()
130+ self._timer_id = self.startTimer(1000)
131+
132+ def hideEvent(self, event):
133+ """Executed when the transfers menu is hidden."""
134+ logger.info('This is never executed on Ubuntu')
135+ super(TransfersMenu, self).hideEvent(event)
136+ self.killTimer(self._timer_id)
137+
138+ def timerEvent(self, event):
139+ """Update the menu on each iteration."""
140+ self.get_transfers_data()
141+
142+ # pylint: enable=C0103
143+
144+ @inlineCallbacks
145+ def get_transfers_data(self):
146+ """Get the transfers data to create the submenu."""
147+ data = yield self._parent.backend.sync_menu()
148+ self._update_transfers(data)
149+
150+ def _update_transfers(self, data):
151+ """Generate the transfers menu."""
152+ current_transfers = data[RECENTTRANSFERS]
153+ current_upload = [
154+ filename for filename, _, _ in data[UPLOADING]]
155+ uploading_data = data[UPLOADING]
156+ uploading_data.sort(key=itemgetter(2))
157+ uploading_data.reverse()
158+ if current_transfers != self.previous_data.get('transfers') or \
159+ current_upload != self.previous_data.get('uploading'):
160+ self.clear()
161+ self.previous_data['transfers'] = current_transfers
162+ self.previous_data['uploading'] = current_upload
163+ self.uploading.clear()
164+ recent = self.addAction(RECENT_TRANSFERS)
165+ recent.setEnabled(False)
166+ for filename in data[RECENTTRANSFERS]:
167+ self.addAction(os.path.basename(filename))
168+ self.addSeparator()
169+ in_progress = self.addAction(IN_PROGRESS)
170+ in_progress.setEnabled(False)
171+ show_max = 0
172+ for filename, size, written in uploading_data:
173+ if show_max == 5:
174+ break
175+ percentage = written * 100 / size
176+ self.uploading[filename] = ProgressBarAction(
177+ filename, percentage)
178+ self.addAction(self.uploading[filename])
179+ show_max += 1
180+ else:
181+ for filename, size, written in uploading_data:
182+ percentage = written * 100 / size
183+ if filename in self.uploading:
184+ self.uploading[filename].set_value(percentage)
185
186=== modified file 'ubuntuone/controlpanel/gui/qt/tests/__init__.py'
187--- ubuntuone/controlpanel/gui/qt/tests/__init__.py 2012-04-02 11:10:49 +0000
188+++ ubuntuone/controlpanel/gui/qt/tests/__init__.py 2012-08-20 12:54:22 +0000
189@@ -25,7 +25,11 @@
190
191 from ubuntuone.controlpanel import backend, cache
192 from ubuntuone.controlpanel.tests import TestCase, EXPECTED_ACCOUNT_INFO, TOKEN
193-from ubuntuone.controlpanel.gui import qt
194+from ubuntuone.controlpanel.gui import (
195+ qt,
196+ RECENTTRANSFERS,
197+ UPLOADING,
198+)
199 from ubuntuone.controlpanel.gui.tests import (
200 FakedObject,
201 FAKE_VOLUMES_INFO,
202@@ -164,6 +168,13 @@
203 def build_signed_iri(self, iri):
204 """Fake iri signing."""
205
206+ def sync_menu(self):
207+ """Fake sync_menu."""
208+ data = {}
209+ data[RECENTTRANSFERS] = []
210+ data[UPLOADING] = []
211+ return data
212+
213
214 class CrashyBackendException(Exception):
215 """A faked backend crash."""
216
217=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_systray.py'
218--- ubuntuone/controlpanel/gui/qt/tests/test_systray.py 2012-08-14 18:55:56 +0000
219+++ ubuntuone/controlpanel/gui/qt/tests/test_systray.py 2012-08-20 12:54:22 +0000
220@@ -22,7 +22,14 @@
221 from twisted.internet.defer import inlineCallbacks
222
223 import ubuntuone.controlpanel.gui.qt.gui
224-from ubuntuone.controlpanel.gui import qt
225+from ubuntuone.controlpanel.gui import (
226+ qt,
227+ IN_PROGRESS,
228+ IN_PROGRESS_FILE,
229+ RECENT_TRANSFERS,
230+ RECENTTRANSFERS,
231+ UPLOADING,
232+)
233 from ubuntuone.controlpanel.gui.qt import systray
234 from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase
235 from ubuntuone.controlpanel.tests import ROOT_PATH
236@@ -73,6 +80,7 @@
237
238 @inlineCallbacks
239 def setUp(self):
240+ self.patch(systray.TransfersMenu, "startTimer", lambda s, x: None)
241 yield super(SystrayTestCase, self).setUp()
242 self.patch(QtGui, "QDesktopServices", FakeDesktopService)
243
244@@ -194,6 +202,7 @@
245 """Test the quit option in the menu."""
246 # Not done on setup, because if I patch stop
247 # after instantiation, it doesn't get called.
248+ self.patch(systray.TransfersMenu, "startTimer", lambda s, x: None)
249 self.patch(systray.TrayIcon, "stop", self._set_called)
250 tray = systray.TrayIcon()
251 tray.quit.trigger()
252@@ -203,6 +212,7 @@
253 def test_stop_sd(self):
254 """Quit should call SyncDaemonTool.quit()."""
255 st = FakeSDTool()
256+ self.patch(systray.TransfersMenu, "startTimer", lambda s, x: None)
257 self.patch(systray, "SyncDaemonTool", lambda: st)
258 tray = systray.TrayIcon()
259 yield tray.stop()
260@@ -210,6 +220,7 @@
261
262 def test_restore_no_window(self):
263 """Test the restore window option in the menu, with no window."""
264+ self.patch(systray.TransfersMenu, "startTimer", lambda s, x: None)
265 self.patch(ubuntuone.controlpanel.gui.qt.gui,
266 "MainWindow", FakeMainWindow)
267 tray = systray.TrayIcon()
268@@ -222,6 +233,7 @@
269
270 def test_restore_window(self):
271 """Test the restore window option in the menu, with a window."""
272+ self.patch(systray.TransfersMenu, "startTimer", lambda s, x: None)
273 tray = systray.TrayIcon()
274 window = FakeMainWindow()
275 tray.window = window
276@@ -232,6 +244,7 @@
277
278 def test_restore_window_minimized(self):
279 """Test the restore window option in the menu, with a min. window."""
280+ self.patch(systray.TransfersMenu, "startTimer", lambda s, x: None)
281 tray = systray.TrayIcon()
282 window = FakeMainWindow()
283 # This cannot be tested with the real activateWindow
284@@ -244,6 +257,7 @@
285
286 def test_delete_window(self):
287 """Test deleting an existing window."""
288+ self.patch(systray.TransfersMenu, "startTimer", lambda s, x: None)
289 tray = systray.TrayIcon()
290 window = FakeMainWindow()
291 tray.window = window
292@@ -253,6 +267,7 @@
293
294 def test_delete_no_window(self):
295 """Test deleting without an existing window."""
296+ self.patch(systray.TransfersMenu, "startTimer", lambda s, x: None)
297 tray = systray.TrayIcon()
298 tray.delete_window()
299 self.assertEqual(tray.window, None)
300@@ -287,6 +302,7 @@
301
302 def test_initialization(self):
303 """Test that everything initializes correctly."""
304+ self.patch(systray.TransfersMenu, "startTimer", lambda s, x: None)
305 tray = systray.TrayIcon()
306 self.assertTrue(tray.isVisible())
307 self.assertEqual(tray.window, None)
308@@ -301,7 +317,223 @@
309 self.assertIsInstance(tray.go_to_web, QtGui.QAction)
310 self.assertIsInstance(tray.get_more_storage, QtGui.QAction)
311 self.assertIsInstance(tray.get_help_online, QtGui.QAction)
312+ self.assertIsInstance(tray.transfers, QtGui.QMenu)
313 # This checks that _get_volumes_info and _process_volumes_info
314 # is being called correctly on initialization.
315 expected_home = u'file://%s' % ROOT_PATH
316 self.assertEqual(tray.root_path, expected_home)
317+
318+ def test_get_transfers_data(self):
319+ """Check that _get_transfers_data return the proper data."""
320+
321+ result = []
322+
323+ def fake_callback(data):
324+ """Fake callback to process data."""
325+ result.append(data)
326+
327+ self.patch(self.ui.transfers, "_update_transfers", fake_callback)
328+ self.ui.transfers.get_transfers_data()
329+ self.assertEqual(result, [{RECENTTRANSFERS: [], UPLOADING: []}])
330+
331+
332+class TransfersMenuTestCase(BaseTestCase):
333+
334+ """Test the notification area icon."""
335+
336+ class_ui = systray.TrayIcon
337+
338+ @inlineCallbacks
339+ def setUp(self):
340+ self.patch(systray.TransfersMenu, "startTimer", lambda s, x: None)
341+ yield super(TransfersMenuTestCase, self).setUp()
342+ self.patch(QtGui, "QDesktopServices", FakeDesktopService)
343+ self.patch(self.ui.transfers._parent.backend, "sync_menu",
344+ self.fake_sync_menu)
345+ self.recent_transfers = []
346+ self.uploading = []
347+
348+ def fake_sync_menu(self):
349+ """Fake backend sync_menu."""
350+ return {RECENTTRANSFERS: self.recent_transfers,
351+ UPLOADING: self.uploading}
352+
353+ def test_load_menu(self):
354+ """Show the menu with just the labels."""
355+ self.ui.transfers.get_transfers_data()
356+ actions = self.ui.transfers.actions()
357+ self.assertEqual(actions[0].text(), RECENT_TRANSFERS)
358+ self.assertTrue(actions[1].isSeparator())
359+ self.assertEqual(actions[2].text(), IN_PROGRESS)
360+
361+ def test_load_recent_transfers(self):
362+ """Show the menu with the recent transfers."""
363+ self.recent_transfers = ['file1', 'file2']
364+ self.ui.transfers.get_transfers_data()
365+ actions = self.ui.transfers.actions()
366+ self.assertEqual(actions[0].text(), RECENT_TRANSFERS)
367+ self.assertEqual(actions[1].text(), 'file1')
368+ self.assertEqual(actions[2].text(), 'file2')
369+ self.assertTrue(actions[3].isSeparator())
370+ self.assertEqual(actions[4].text(), IN_PROGRESS)
371+
372+ def test_load_in_progress(self):
373+ """Show the menu with the current progress."""
374+ in_progress = [
375+ ('file1', 200, 150),
376+ ('file2', 400, 100),
377+ ('file3', 300, 200),
378+ ]
379+
380+ # Return copy of in_progress
381+ self.uploading = in_progress[:]
382+ self.ui.transfers.get_transfers_data()
383+ actions = self.ui.transfers.actions()
384+ self.assertEqual(actions[0].text(), RECENT_TRANSFERS)
385+ self.assertTrue(actions[1].isSeparator())
386+ self.assertEqual(actions[2].text(), IN_PROGRESS)
387+
388+ # This also check that the files are ordered based on written
389+ percentage = in_progress[2][2] * 100 / in_progress[2][1]
390+ text = IN_PROGRESS_FILE % (in_progress[2][0], percentage)
391+ self.assertEqual(actions[3].label.text(), text)
392+ self.assertEqual(actions[3].progress.value(), percentage)
393+
394+ percentage = in_progress[0][2] * 100 / in_progress[0][1]
395+ text = IN_PROGRESS_FILE % (in_progress[0][0], percentage)
396+ self.assertEqual(actions[4].label.text(), text)
397+ self.assertEqual(actions[4].progress.value(), percentage)
398+
399+ percentage = in_progress[1][2] * 100 / in_progress[1][1]
400+ text = IN_PROGRESS_FILE % (in_progress[1][0], percentage)
401+ self.assertEqual(actions[5].label.text(), text)
402+ self.assertEqual(actions[5].progress.value(), percentage)
403+
404+ def test_load_in_progress_refresh(self):
405+ """Show the menu with the current progress and refresh it."""
406+ in_progress = [
407+ ('file1', 200, 150),
408+ ('file2', 400, 100),
409+ ('file3', 300, 200),
410+ ]
411+ # Return copy of in_progress
412+ self.uploading = in_progress[:]
413+ self.ui.transfers.get_transfers_data()
414+ actions = self.ui.transfers.actions()
415+ self.assertEqual(actions[0].text(), RECENT_TRANSFERS)
416+ self.assertTrue(actions[1].isSeparator())
417+ self.assertEqual(actions[2].text(), IN_PROGRESS)
418+
419+ # This also check that the files are ordered based on written
420+ previous_actions = []
421+ percentage = in_progress[2][2] * 100 / in_progress[2][1]
422+ text = IN_PROGRESS_FILE % (in_progress[2][0], percentage)
423+ self.assertEqual(actions[3].text(), text)
424+ previous_actions.append(actions[3])
425+
426+ percentage = in_progress[0][2] * 100 / in_progress[0][1]
427+ text = IN_PROGRESS_FILE % (in_progress[0][0], percentage)
428+ self.assertEqual(actions[4].text(), text)
429+ previous_actions.append(actions[4])
430+
431+ percentage = in_progress[1][2] * 100 / in_progress[1][1]
432+ text = IN_PROGRESS_FILE % (in_progress[1][0], percentage)
433+ self.assertEqual(actions[5].text(), text)
434+ previous_actions.append(actions[5])
435+
436+ in_progress = [
437+ ('file1', 200, 170),
438+ ('file2', 400, 300),
439+ ('file3', 300, 210),
440+ ]
441+ self.uploading = in_progress[:]
442+
443+ self.ui.transfers.get_transfers_data()
444+ actions = self.ui.transfers.actions()
445+ current_actions = []
446+ self.assertEqual(actions[0].text(), RECENT_TRANSFERS)
447+ self.assertTrue(actions[1].isSeparator())
448+ self.assertEqual(actions[2].text(), IN_PROGRESS)
449+
450+ # This also check that the files are ordered based on written
451+ percentage = in_progress[2][2] * 100 / in_progress[2][1]
452+ text = IN_PROGRESS_FILE % (in_progress[2][0], percentage)
453+ self.assertEqual(actions[3].text(), text)
454+ current_actions.append(actions[3])
455+
456+ percentage = in_progress[0][2] * 100 / in_progress[0][1]
457+ text = IN_PROGRESS_FILE % (in_progress[0][0], percentage)
458+ self.assertEqual(actions[4].text(), text)
459+ current_actions.append(actions[4])
460+
461+ percentage = in_progress[1][2] * 100 / in_progress[1][1]
462+ text = IN_PROGRESS_FILE % (in_progress[1][0], percentage)
463+ self.assertEqual(actions[5].text(), text)
464+ current_actions.append(actions[5])
465+
466+ self.assertEqual(previous_actions, current_actions)
467+
468+ def test_menu_not_reload(self):
469+ """Show the menu and test that is not reload it on refresh."""
470+ self.recent_transfers = ['file1', 'file2']
471+ self.ui.transfers.get_transfers_data()
472+ previous_actions = self.ui.transfers.actions()
473+ self.ui.transfers.get_transfers_data()
474+ current_actions = self.ui.transfers.actions()
475+ self.assertEqual(previous_actions, current_actions)
476+
477+ def test_menu_reload(self):
478+ """Show the menu and test that is reload it on refresh."""
479+ self.recent_transfers = ['file1', 'file2']
480+ self.ui.transfers.get_transfers_data()
481+ previous_actions = self.ui.transfers.actions()
482+ self.recent_transfers = ['file1', 'file2', 'file3']
483+
484+ self.ui.transfers.get_transfers_data()
485+ current_actions = self.ui.transfers.actions()
486+ self.assertNotEqual(previous_actions, current_actions)
487+
488+ def test_progress_not_reload(self):
489+ """Show the menu and test that is not reload it on refresh."""
490+ in_progress = [
491+ ('file1', 200, 150),
492+ ('file2', 400, 100),
493+ ('file3', 300, 200),
494+ ]
495+ # Return copy of in_progress
496+ self.uploading = in_progress[:]
497+ self.ui.transfers.get_transfers_data()
498+ previous_actions = self.ui.transfers.actions()
499+ in_progress = [
500+ ('file1', 200, 170),
501+ ('file2', 400, 300),
502+ ('file3', 300, 210),
503+ ]
504+ self.uploading = in_progress[:]
505+ self.ui.transfers.get_transfers_data()
506+ current_actions = self.ui.transfers.actions()
507+
508+ self.assertEqual(previous_actions, current_actions)
509+
510+ def test_progress_reload(self):
511+ """Show the menu and test that is reload it on refresh."""
512+ in_progress = [
513+ ('file1', 200, 150),
514+ ('file2', 400, 100),
515+ ('file3', 300, 200),
516+ ]
517+ # Return copy of in_progress
518+ self.uploading = in_progress[:]
519+ self.ui.transfers.get_transfers_data()
520+ previous_actions = self.ui.transfers.actions()
521+ in_progress = [
522+ ('file1', 200, 170),
523+ ('file2', 400, 300),
524+ ('file3', 300, 210),
525+ ('file4', 1000, 410),
526+ ]
527+ self.uploading = in_progress[:]
528+ self.ui.transfers.get_transfers_data()
529+ current_actions = self.ui.transfers.actions()
530+
531+ self.assertNotEqual(previous_actions, current_actions)

Subscribers

People subscribed via source and target branches