Merge lp:~nataliabidart/ubuntuone-control-panel/quota-exceeded-on-shares into lp:ubuntuone-control-panel

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 134
Merged at revision: 131
Proposed branch: lp:~nataliabidart/ubuntuone-control-panel/quota-exceeded-on-shares
Merge into: lp:ubuntuone-control-panel
Diff against target: 159 lines (+62/-10)
4 files modified
ubuntuone/controlpanel/backend.py (+6/-2)
ubuntuone/controlpanel/gtk/gui.py (+17/-5)
ubuntuone/controlpanel/gtk/tests/__init__.py (+11/-2)
ubuntuone/controlpanel/gtk/tests/test_gui.py (+28/-1)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-control-panel/quota-exceeded-on-shares
Reviewer Review Type Date Requested Status
Roman Yepishev (community) fieldtest Approve
Eric Casteleijn (community) Approve
Review via email: mp+56857@code.launchpad.net

Commit message

- Highlight with red and bold when free space available is very little (either in own volumes or shares) (LP: #753989).

Description of the change

Screenshot located at http://ubuntuone.com/p/fMq/

To post a comment you must log in.
Revision history for this message
Eric Casteleijn (thisfred) wrote :

looks great

review: Approve
Revision history for this message
Roman Yepishev (rye) wrote :

Approving, noting that this will cause read-only shares to be highlighted with a warning-like "0 bytes available storage" - http://ubuntuone.com/p/leT/

review: Approve (fieldtest)
Revision history for this message
Natalia Bidart (nataliabidart) wrote :
Download full text (80.2 KiB)

The attempt to merge lp:~nataliabidart/ubuntuone-control-panel/quota-exceeded-on-shares into lp:ubuntuone-control-panel failed. Below is the output from the failed tests.

Running test suite for ubuntuone/controlpanel
Xlib: extension "RANDR" missing on display ":99".
ubuntuone.controlpanel.gtk.tests
  BaseTestCase
    runTest ... [OK]
ubuntuone.controlpanel.gtk.tests.test_gui_basic
  ControlPanelMixinTestCase
    test_is_a_control_panel_mixin ... [OK]
    test_ui_can_be_created ... [OK]
  ControlPanelTestCase
    test_backend_is_shutdown_on_close ... [OK]
    test_credentials_found_connects_syncdaemon ... [OK]
    test_credentials_found_shows_dashboard_panel ... [OK]
    test_credentials_found_shows_services_panel ... [OK]
    test_is_a_notebook ... [OK]
    test_local_device_removed_shows_overview_panel ... [OK]
    test_main_window_is_passed_to_child ... [OK]
    test_on_show_management_panel ... [OK]
    test_on_show_management_panel_is_idempotent ... [OK]
    test_overview_is_shown_at_startup ... [OK]
    test_startup_props ... [OK]
    test_startup_visibility ... [OK]
    test_unauthorized_shows_overview_panel ... [OK]
  ControlPanelWindowAlertParamTestCase
    test_alert ... [OK]
  ControlPanelWindowInvalidParamsTestCase
    test_closing_stops_the_main_lopp ... [OK]
    test_control_panel_is_the_only_child ... [OK]
    test_focus_handler ... [OK]
    test_icon_name_is_correct ... [OK]
    test_is_a_window ... [OK]
    test_main_start_gtk_main_loop ... [OK]
    test_main_window_is_passed_to_child ... [OK]
    test_max_size ... [OK]
    test_startup_visibility ... [OK]
    test_switch_to ... [OK]
    test_title_is_correct ... [OK]
  ControlPanelWindowParamsNoneTestCase
    test_closing_stops_the_main_lopp ... [OK]
    test_control_panel_is_the_only_child ... [OK]
    test_focus_handler ... [OK]
    test_icon_name_is_correct ... [OK]
    test_is_a_window ... [OK]
    test_main_start_gtk_...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/controlpanel/backend.py'
2--- ubuntuone/controlpanel/backend.py 2011-04-06 22:22:37 +0000
3+++ ubuntuone/controlpanel/backend.py 2011-04-08 14:31:38 +0000
4@@ -468,7 +468,9 @@
5 share[u'type'] = self.SHARE_TYPE
6
7 vid = share['volume_id']
8- assert vid not in self._volumes
9+ if vid in self._volumes:
10+ logger.warning('volumes_info: share %r already in the volumes '
11+ 'list (%r).', vid, self._volumes[vid])
12 self._volumes[vid] = share
13
14 if not bool(share['accepted']):
15@@ -488,7 +490,9 @@
16 folder[u'type'] = self.FOLDER_TYPE
17
18 vid = folder['volume_id']
19- assert vid not in self._volumes
20+ if vid in self._volumes:
21+ logger.warning('volumes_info: udf %r already in the volumes '
22+ 'list (%r).', vid, self._volumes[vid])
23 self._volumes[vid] = folder
24
25 result = [(u'', unicode(free_bytes), [root_volume] + folders)]
26
27=== modified file 'ubuntuone/controlpanel/gtk/gui.py'
28--- ubuntuone/controlpanel/gtk/gui.py 2011-04-07 19:00:54 +0000
29+++ ubuntuone/controlpanel/gtk/gui.py 2011-04-08 14:31:38 +0000
30@@ -456,7 +456,7 @@
31 'this computer')
32 MY_FOLDERS = _('My folders')
33 ALWAYS_SUBSCRIBED = _('Always in sync!')
34- FREE_SPACE = _('%(free_space)s available storage')
35+ FREE_SPACE_TEXT = _('%(free_space)s available storage')
36 NO_VOLUMES = _('No folders to show.')
37 NAME_NOT_SET = _('[unknown user name]')
38 CONFIRM_MERGE = _('The contents of your cloud folder will be merged with '
39@@ -466,13 +466,15 @@
40 MUSIC_REAL_PATH = '~/.ubuntuone/Purchased from Ubuntu One'
41
42 MAX_COLS = 8
43+ MIN_SIZE_FULL = 1048576
44
45 CONTACT_ICON_NAME = 'avatar-default'
46 FOLDER_ICON_NAME = 'folder'
47 SHARE_ICON_NAME = 'folder-remote'
48 MUSIC_ICON_NAME = 'audio-x-generic'
49- ROW_HEADER = '<span font_size="large"><b>%s</b></span> ' \
50- '<span foreground="grey">%s</span>'
51+ FREE_SPACE = '<span foreground="grey">%s</span>' % FREE_SPACE_TEXT
52+ NO_FREE_SPACE = '<span foreground="red"><b>%s</b></span>' % FREE_SPACE_TEXT
53+ ROW_HEADER = '<span font_size="large"><b>%s</b></span> %s'
54 ROOT = '%s - <span foreground="%s" font_size="small">%s</span>'
55
56 def __init__(self, main_window=None):
57@@ -534,12 +536,22 @@
58 else:
59 name = self.MY_FOLDERS
60
61- free_bytes_args = {'free_space': self.humanize(int(free_bytes))}
62- row = (self.ROW_HEADER % (name, self.FREE_SPACE % free_bytes_args),
63+ free_bytes = int(free_bytes)
64+ if free_bytes < self.MIN_SIZE_FULL:
65+ free_bytes_str = self.NO_FREE_SPACE
66+ else:
67+ free_bytes_str = self.FREE_SPACE
68+
69+ free_bytes_args = {'free_space': self.humanize(free_bytes)}
70+ row = (self.ROW_HEADER % (name, free_bytes_str % free_bytes_args),
71 True, self.CONTACT_ICON_NAME, False, False,
72 gtk.ICON_SIZE_LARGE_TOOLBAR, None, None)
73 treeiter = self.volumes_store.append(None, row)
74
75+ if free_bytes < self.MIN_SIZE_FULL:
76+ path = self.volumes_store.get_string_from_iter(treeiter)
77+ self.volumes_view.scroll_to_cell(path)
78+
79 volumes.sort(key=operator.itemgetter('path'))
80 for volume in volumes:
81 sensitive = True
82
83=== modified file 'ubuntuone/controlpanel/gtk/tests/__init__.py'
84--- ubuntuone/controlpanel/gtk/tests/__init__.py 2011-03-29 19:14:21 +0000
85+++ ubuntuone/controlpanel/gtk/tests/__init__.py 2011-04-08 14:31:38 +0000
86@@ -68,7 +68,6 @@
87 {u'volume_id': u'1234', u'name': u'do',
88 u'path': u'/home/tester/.local/share/ubuntuone/shares/do from Other User',
89 u'subscribed': u'', u'type': ControlBackend.SHARE_TYPE},
90-
91 {u'volume_id': u'5678', u'name': u're',
92 u'path': u'/home/tester/.local/share/ubuntuone/shares/re from Other User',
93 u'subscribed': u'True', u'type': ControlBackend.SHARE_TYPE},
94@@ -76,7 +75,17 @@
95
96 FAKE_VOLUMES_INFO = [
97 (u'', u'147852369', [ROOT] + FAKE_FOLDERS_INFO),
98- (u'Other User', u'985674', FAKE_SHARES_INFO),
99+ (u'Other User', gui.VolumesPanel.MIN_SIZE_FULL, FAKE_SHARES_INFO),
100+]
101+
102+FAKE_VOLUMES_NO_FREE_SPACE_INFO = [
103+ (u'', u'500', [ROOT]),
104+ (u'No free space', u'0',
105+ [{u'volume_id': u'0', u'name': u'full', u'path': u'full-share',
106+ u'subscribed': u'', u'type': ControlBackend.SHARE_TYPE}]),
107+ (u'Almost no free space', gui.VolumesPanel.MIN_SIZE_FULL - 1,
108+ [{u'volume_id': u'1', u'name': u'almostfull', u'path': u'almost-full',
109+ u'subscribed': u'', u'type': ControlBackend.SHARE_TYPE}]),
110 ]
111
112 FAKE_DEVICE_INFO = {
113
114=== modified file 'ubuntuone/controlpanel/gtk/tests/test_gui.py'
115--- ubuntuone/controlpanel/gtk/tests/test_gui.py 2011-04-06 21:05:37 +0000
116+++ ubuntuone/controlpanel/gtk/tests/test_gui.py 2011-04-08 14:31:38 +0000
117@@ -23,7 +23,7 @@
118 from ubuntuone.controlpanel.gtk import gui
119 from ubuntuone.controlpanel.gtk.tests import (FAKE_ACCOUNT_INFO,
120 FAKE_DEVICE_INFO, FAKE_DEVICES_INFO, FAKE_FOLDERS_INFO,
121- FAKE_VOLUMES_INFO, FAKE_REPLICATIONS_INFO,
122+ FAKE_VOLUMES_INFO, FAKE_VOLUMES_NO_FREE_SPACE_INFO, FAKE_REPLICATIONS_INFO,
123 MUSIC_FOLDER, ROOT, USER_HOME,
124 FakedConfirmDialog,
125 )
126@@ -260,6 +260,33 @@
127
128 self.assertEqual(len(self.ui.volumes_store), 0)
129
130+ def test_on_volumes_info_ready_highlights_little_free_space(self):
131+ """The free space is red if is zero (or close to 0)."""
132+ self.ui.on_volumes_info_ready(FAKE_VOLUMES_NO_FREE_SPACE_INFO)
133+
134+ treeiter = self.ui.volumes_store.get_iter_root()
135+ for name, free_bytes, volumes in FAKE_VOLUMES_NO_FREE_SPACE_INFO:
136+ name = "%s's" % name if name else self.ui.MY_FOLDERS
137+ free_bytes = self.ui.humanize(int(free_bytes))
138+ free_bytes = self.ui.NO_FREE_SPACE % {'free_space': free_bytes}
139+
140+ # check parent row
141+ row = self.ui.volumes_store.get(treeiter,
142+ *xrange(self.ui.MAX_COLS))
143+
144+ self.assertEqual(row[0], self.ui.ROW_HEADER % (name, free_bytes))
145+
146+ treeiter = self.ui.volumes_store.iter_next(treeiter)
147+
148+ if treeiter is not None:
149+ # skip the empty row
150+ row = self.ui.volumes_store.get(treeiter,
151+ *xrange(self.ui.MAX_COLS))
152+ self.assertEqual(row, self.ui._empty_row)
153+
154+ # grab next non-empty row
155+ treeiter = self.ui.volumes_store.iter_next(treeiter)
156+
157 def test_on_volumes_info_error(self):
158 """The volumes info couldn't be retrieved."""
159 self.ui.on_volumes_info_error()

Subscribers

People subscribed via source and target branches