Merge lp:~chipaca/ubuntuone-client/some-account-tab-fixes into lp:ubuntuone-client

Proposed by John Lenton
Status: Merged
Approved by: John Lenton
Approved revision: 461
Merged at revision: not available
Proposed branch: lp:~chipaca/ubuntuone-client/some-account-tab-fixes
Merge into: lp:ubuntuone-client
Diff against target: 276 lines (+190/-13)
2 files modified
bin/ubuntuone-preferences (+90/-13)
tests/test_preferences.py (+100/-0)
To merge this branch: bzr merge lp:~chipaca/ubuntuone-client/some-account-tab-fixes
Reviewer Review Type Date Requested Status
Matt Griffin (community) Approve
Stuart Langridge (community) Approve
Facundo Batista (community) Approve
Review via email: mp+22354@code.launchpad.net

Commit message

This adds the overquota notices and warnings, as well as a couple of ui elements that we missed. Fixes #540360.

Description of the change

This adds the overquota notices and warnings, as well as a couple of ui elements that we missed. Fixes #540360.

To post a comment you must log in.
457. By John Lenton

merged with trunk r451

458. By John Lenton

merged with trunk r452

Revision history for this message
Facundo Batista (facundo) wrote :
Download full text (16.4 KiB)

tests.test_preferences
  PreferencesTests
    test_bw_throttling ... [OK]
    test_list_devices_fills_devices_list_with_fake_result_when_empty ... [OK]
    test_list_devices_shows_devices_list ... [OK]
    test_list_devices_shows_real_devices_list ... [OK]
    test_login_check ... [OK]
    test_no_overquota_notice_on_low_usage ... Traceback (most recent call last):
  File "/home/facundo/canonical/u1-client/review_some-account-tab-fixes/contrib/mocker.py", line 102, in test_method_wrapper
    result = test_method()
  File "/home/facundo/canonical/u1-client/review_some-account-tab-fixes/tests/test_preferences.py", line 232, in test_no_overquota_notice_on_low_usage
    dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)
  File "/home/facundo/canonical/u1-client/review_some-account-tab-fixes/bin/ubuntuone-preferences", line 474, in __init__
    self.__construct()
  File "/home/facundo/canonical/u1-client/review_some-account-tab-fixes/bin/ubuntuone-preferences", line 759, in __construct
    self.update_quota_display(0, 2)
  File "/home/facundo/canonical/u1-client/review_some-account-tab-fixes/bin/ubuntuone-preferences", line 566, in update_quota_display
    self.plan_label.set_label(_("Payed") if is_payed_account else _("Free"))
exceptions.AttributeError: 'UbuntuOneDialog' object has no attribute 'plan_label'
[ERROR]
Traceback (most recent call last):
  File "/home/facundo/canonical/u1-client/review_some-account-tab-fixes/bin/ubuntuone-preferences", line 521, in __got_state
    self.status_label.set_text(_("Synchronization complete"))
exceptions.AttributeError: 'UbuntuOneDialog' object has no attribute 'status_label'
[ERROR]
    test_overquota_notice_and_not_upgrade_offer_on_payed_high_usage ... Traceback (most recent call last):
  File "/home/facundo/canonical/u1-client/review_some-account-tab-fixes/contrib/mocker.py", line 102, in test_method_wrapper
    result = test_method()
  File "/home/facundo/canonical/u1-client/review_some-account-tab-fixes/tests/test_preferences.py", line 268, in test_overquota_notice_and_not_upgrade_offer_on_payed_high_usage
    dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)
  File "/home/facundo/canonical/u1-client/review_some-account-tab-fixes/bin/ubuntuone-preferences", line 474, in __init__
    self.__construct()
  File "/home/facundo/canonical/u1-client/review_some-account-tab-fixes/bin/ubuntuone-preferences", line 759, in __construct
    self.update_quota_display(0, 2)
  File "/home/facundo/canonical/u1-client/review_some-account-tab-fixes/bin/ubuntuone-preferences", line 566, in update_quota_display
    self.plan_label.set_label(_("Payed") if is_payed_account else _("Free"))
exceptions.AttributeError: 'UbuntuOneDialog' object has no attribute 'plan_label'
[ERROR]
Traceback (most recent call last):
  File "/home/facundo/canonical/u1-client/review_some-account-tab-fixes/bin/ubuntuone-preferences", line 521, in __got_state
    self.status_label.set_text(_("Synchronization complete"))
exceptions.AttributeError: 'UbuntuOneDialog' object has no a...

review: Needs Fixing
459. By John Lenton

oops, bad merge

460. By John Lenton

fixes as per mattgriffin

Revision history for this message
Facundo Batista (facundo) wrote :

It's ok now.

review: Approve
Revision history for this message
Stuart Langridge (sil) wrote :

"Payed" should be "Paid" in all locations, I think.

review: Needs Fixing
461. By John Lenton

"payed" is not, apparently, English

Revision history for this message
Stuart Langridge (sil) wrote :

rock.

review: Approve
Revision history for this message
Matt Griffin (mattgriffin) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/ubuntuone-preferences'
2--- bin/ubuntuone-preferences 2010-03-29 21:54:19 +0000
3+++ bin/ubuntuone-preferences 2010-03-29 21:59:26 +0000
4@@ -462,6 +462,17 @@
5 self.__bus = dbus.SessionBus()
6 self.keyring = keyring
7
8+ # Timeout ID to avoid spamming DBus from spinbutton changes
9+ self.__update_id = 0
10+
11+ # SD Tool object
12+ self.sdtool = SyncDaemonTool(self.__bus)
13+ self.sdtool.get_status().addCallbacks(self.__got_state,
14+ self.__sd_error)
15+ # Build the dialog
16+ self.__construct()
17+
18+ # hook dbus up
19 self.__bus.add_signal_receiver(
20 handler_function=self.__got_state,
21 signal_name='StatusChanged',
22@@ -480,16 +491,6 @@
23 except DBusException, e:
24 self.__dbus_error(e)
25
26- # Timeout ID to avoid spamming DBus from spinbutton changes
27- self.__update_id = 0
28-
29- # Build the dialog
30- self.__construct()
31-
32- # SD Tool object
33- self.sdtool = SyncDaemonTool(self.__bus)
34- self.sdtool.get_status().addCallbacks(self.__got_state,
35- self.__sd_error)
36 logger.debug("starting")
37
38 def quit(self):
39@@ -559,6 +560,42 @@
40 'percent' : percent })
41 self.usage_graph.set_fraction(percent / 100)
42
43+ # assumes all paid accounts will have more than 50GB
44+ is_paid_account = total >= 50<<30
45+ self.plan_label.set_label(_("Paid") if is_paid_account else _("Free"))
46+ if is_paid_account:
47+ self.upgrade_link.hide()
48+
49+ if percent >= 100.:
50+ self.overquota_img.set_from_icon_name('dialog-warning',
51+ gtk.ICON_SIZE_DIALOG)
52+ self.overquota.show_all()
53+ label = _("You are using all of your Ubuntu One storage.")
54+ if is_paid_account:
55+ desc = _("Synchronization is now disabled. Remove files from"
56+ " synchronization or upgrade your subscription. Use"
57+ " the Support options if an upgrade is not available.")
58+ else:
59+ desc = _("Synchronization is now disabled. Remove files from"
60+ " synchronization or upgrade your subscription.")
61+ elif percent >= 95.:
62+ self.overquota_img.set_from_icon_name('dialog-information',
63+ gtk.ICON_SIZE_DIALOG)
64+ self.overquota.show_all()
65+ label = _("You are near your Ubuntu One storage limit.")
66+ if is_paid_account:
67+ desc = _("Automatic synchronization will stop when you reach"
68+ " your storage limit.")
69+ else:
70+ desc = _("Automatic synchronization will stop when you reach"
71+ " your storage limit. Please consider upgrading to"
72+ " avoid a service interruption.")
73+ else:
74+ self.overquota_img.clear()
75+ label = desc = ""
76+ self.overquota.hide_all()
77+ self.overquota_label.set_markup("%s\n<small>%s</small>" % (label, desc))
78+
79 def got_quota_info(self, quota):
80 """Handle the result from the quota REST call."""
81 if quota:
82@@ -717,8 +754,6 @@
83 hbox.pack_start(self.usage_label, True, True)
84 self.usage_label.show()
85
86- self.update_quota_display(0, 2)
87-
88 self.status_label = gtk.Label("")
89 self.status_label.set_alignment(0.0, 0.5)
90 rbox.pack_start(self.status_label, False, False)
91@@ -736,8 +771,25 @@
92 self.notebook.set_tab_label_text(account, _("Account"))
93 account.show()
94
95+ # overquota notice in account tab
96+ self.overquota = gtk.HBox(spacing=6)
97+ self.overquota.set_border_width(6)
98+ account.pack_start(self.overquota, False, False)
99+ self.overquota.show()
100+
101+ self.overquota_img = gtk.Image()
102+ self.overquota.pack_start(self.overquota_img, False, False)
103+ self.overquota_img.show()
104+
105+ self.overquota_label = label = gtk.Label("\n\n")
106+ label.set_line_wrap(True)
107+ label.set_alignment(0.0, 0.5)
108+ self.overquota.pack_start(label, False, False)
109+ label.show()
110+
111+
112 # User info in account tab
113- table = gtk.Table(rows=2, columns=2)
114+ table = gtk.Table(rows=6, columns=2)
115 table.set_row_spacings(6)
116 table.set_col_spacings(6)
117 account.pack_start(table, False, False)
118@@ -767,6 +819,29 @@
119 table.attach(self.mail_label, 1, 2, 1, 2)
120 self.mail_label.show()
121
122+ label = gtk.Label(_("Current plan:"))
123+ label.set_alignment(0.0, 0.5)
124+ table.attach(label, 0, 1, 2, 3)
125+ label.show()
126+
127+ self.plan_label = gtk.Label("")
128+ self.plan_label.set_alignment(0.0, 0.5)
129+ table.attach(self.plan_label, 1, 2, 2, 3)
130+ self.plan_label.show()
131+
132+ for n, (url, label) in enumerate([
133+ ("http://one.ubuntu.com/support", _("Support options")),
134+ ("http://one.ubuntu.com/account", _("Manage account")),
135+ ("http://one.ubuntu.com/upgrade",
136+ _("Upgrade your subscription")),
137+ ]):
138+ link = gtk.LinkButton(url, label)
139+ link.set_relief(gtk.RELIEF_NONE)
140+ link.set_alignment(0.0, 0.5)
141+ table.attach(link, 0, 2, 5-n, 6-n)
142+ link.show()
143+ self.upgrade_link = link
144+
145 # Devices tab
146 sw = gtk.ScrolledWindow()
147 sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
148@@ -832,6 +907,8 @@
149 alignment.add(self.music_check)
150 self.music_check.show()
151
152+ # get the quota
153+ self.update_quota_display(0, 2)
154
155 class UbuntuoneLoginHandler(object):
156 """Class to handle registration/login, in case we aren't already."""
157
158=== modified file 'tests/test_preferences.py'
159--- tests/test_preferences.py 2010-03-25 18:30:27 +0000
160+++ tests/test_preferences.py 2010-03-29 21:59:26 +0000
161@@ -225,6 +225,95 @@
162 self.assertEqual(dialog.usage_graph.get_fraction(), 0.5)
163 dialog.destroy()
164
165+ def test_no_overquota_notice_on_low_usage(self):
166+ """Test that the quota notice is not visible if usage is low."""
167+ self.content = {"total":2048, "used":1024}
168+ self.mocker.replay()
169+ dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)
170+ self.assertTrue(dialog is not None)
171+ dialog.request_quota_info()
172+ # the label should just be the blank '\n'
173+ self.assertEqual(dialog.overquota_label.get_text(), '\n')
174+ # and the icon should be blank, too
175+ self.assertEqual(dialog.overquota_img.get_icon_name()[0], None)
176+ dialog.destroy()
177+
178+ def test_overquota_notice_and_upgrade_offer_on_free_high_usage(self):
179+ """Test that the quota notice is visible if usage is 95%.
180+
181+ Also make sure the label mentions upgrading.
182+ """
183+ self.content = {"total": 100, "used": 95}
184+ self.mocker.replay()
185+ dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)
186+ self.assertTrue(dialog is not None)
187+ dialog.request_quota_info()
188+ # don't check the exact text, as it will probably
189+ # change. Check we're setting some amount of text,
190+ self.assertTrue(len(dialog.overquota_label.get_text()) > 100)
191+ # and check that we mention upgrading
192+ self.assertTrue('upgrad' in dialog.overquota_label.get_text().lower())
193+ # and check that the icon used is just informational
194+ self.assertEqual(dialog.overquota_img.get_icon_name()[0],
195+ 'dialog-information')
196+ dialog.destroy()
197+
198+ def test_overquota_notice_and_not_upgrade_offer_on_paid_high_usage(self):
199+ """Test that the quota notice is visible if usage is 95%.
200+
201+ Also make sure the label does not mention upgrading.
202+ """
203+ self.content = {"total": 50<<30, "used": 49<<30}
204+ self.mocker.replay()
205+ dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)
206+ self.assertTrue(dialog is not None)
207+ dialog.request_quota_info()
208+ # don't check the exact text, as it will probably
209+ # change. Check we're setting some amount of text,
210+ self.assertTrue(len(dialog.overquota_label.get_text()) > 100)
211+ # and check that we mention upgrading
212+ self.assertTrue('upgrad' not in
213+ dialog.overquota_label.get_text().lower())
214+ # and check that the icon used is just informational
215+ self.assertEqual(dialog.overquota_img.get_icon_name()[0],
216+ 'dialog-information')
217+ dialog.destroy()
218+
219+ def test_overquota_warning_and_upgrade_offer_there_on_free_over_quota(self):
220+ """Test that the quota notice is visible if usage is 100%.
221+
222+ Also make sure the label mentions upgrading.
223+ """
224+ self.content = {"total": 100, "used": 100}
225+ self.mocker.replay()
226+ dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)
227+ self.assertTrue(dialog is not None)
228+ dialog.request_quota_info()
229+ # don't check the exact text, as it will probably
230+ # change. Check we're setting some amount of text,
231+ self.assertTrue(len(dialog.overquota_label.get_text()) > 100)
232+ # and check that we mention upgrading
233+ self.assertTrue('upgrad' in dialog.overquota_label.get_text().lower())
234+ # and check that the icon used is a warning
235+ self.assertEqual(dialog.overquota_img.get_icon_name()[0],
236+ 'dialog-warning')
237+ dialog.destroy()
238+
239+ def test_overquota_warning_there_on_paid_over_quota(self):
240+ """Test that the quota notice is visible if usage is 100%."""
241+ self.content = {"total": 50<<30, "used": 50<<30}
242+ self.mocker.replay()
243+ dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)
244+ self.assertTrue(dialog is not None)
245+ dialog.request_quota_info()
246+ # don't check the exact text, as it will probably
247+ # change. Check we're setting some amount of text,
248+ self.assertTrue(len(dialog.overquota_label.get_text()) > 100)
249+ # and check that the icon used is a warning
250+ self.assertEqual(dialog.overquota_img.get_icon_name()[0],
251+ 'dialog-warning')
252+ dialog.destroy()
253+
254 def test_request_account_info(self):
255 """Test that we can request the account info properly."""
256 self.content = {"username": "ubuntuone", "nickname": "Ubuntu One",
257@@ -233,8 +322,19 @@
258 dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)
259 self.assertTrue(dialog is not None)
260 dialog.request_account_info()
261+ self.content = {"total":2048, "used":1024}
262+ dialog.request_quota_info()
263 self.assertEqual(dialog.name_label.get_text(), 'Ubuntu One')
264 self.assertEqual(dialog.mail_label.get_text(), 'uone@example.com')
265+ # ensure the plan label says "Free" and the upgrade button is there
266+ self.assertEqual(dialog.plan_label.get_text(), 'Free')
267+ self.assertTrue(dialog.upgrade_link.get_visible())
268+ # whoops, the user upgraded
269+ self.content = {"total": 50<<30, "used":1024}
270+ dialog.request_quota_info()
271+ # ensure the plan label says "Paid" and the upgrade button is not there
272+ self.assertEqual(dialog.plan_label.get_text(), 'Paid')
273+ self.assertFalse(dialog.upgrade_link.get_visible())
274 dialog.destroy()
275
276 def test_toggle_bookmarks(self):

Subscribers

People subscribed via source and target branches