Merge lp:~thisfred/ubuntuone-client/lp-734985 into lp:ubuntuone-client

Proposed by Eric Casteleijn
Status: Merged
Approved by: Eric Casteleijn
Approved revision: 919
Merged at revision: 918
Proposed branch: lp:~thisfred/ubuntuone-client/lp-734985
Merge into: lp:ubuntuone-client
Diff against target: 114 lines (+18/-15)
2 files modified
tests/status/test_aggregator.py (+7/-7)
ubuntuone/status/aggregator.py (+11/-8)
To merge this branch: bzr merge lp:~thisfred/ubuntuone-client/lp-734985
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
dobey (community) Approve
Review via email: mp+53296@code.launchpad.net

Commit message

This makes the code use a single instance of the ubuntuone.platform.notification.Notification class.

Description of the change

This makes the code use a single instance of the ubuntuone.platform.notification.Notification class.

To post a comment you must log in.
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Looks good

review: Approve

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 2011-03-10 14:48:06 +0000
3+++ tests/status/test_aggregator.py 2011-03-14 18:40:16 +0000
4@@ -230,9 +230,9 @@
5 """Reset the progress bubble."""
6 self.restart_progress_bubble_called = True
7
8- def build_notification(self):
9+ def get_notification(self):
10 """Create a new toggleable notification object."""
11- return self.notification_switch.build_notification()
12+ return self.notification_switch.get_notification()
13
14
15 class ToggleableNotificationTestCase(TestCase):
16@@ -242,7 +242,7 @@
17 """Initialize this test instance."""
18 self.patch(aggregator, "Notification", FakeNotification)
19 self.notification_switch = aggregator.NotificationSwitch()
20- self.toggleable = self.notification_switch.build_notification()
21+ self.toggleable = self.notification_switch.get_notification()
22
23 def assertShown(self, notification):
24 """Assert that the notification was shown."""
25@@ -282,9 +282,9 @@
26 """Initialize this test instance."""
27 self.notification_switch = aggregator.NotificationSwitch()
28
29- def test_build_notification(self):
30+ def test_get_notification(self):
31 """A new notification instance is returned."""
32- notification = self.notification_switch.build_notification()
33+ notification = self.notification_switch.get_notification()
34 self.assertEqual(notification.notification_switch,
35 self.notification_switch)
36
37@@ -796,9 +796,9 @@
38 """A new command was unqueued."""
39 self.queued_commands.discard(command)
40
41- def build_notification(self):
42+ def get_notification(self):
43 """Create a new toggleable notification object."""
44- return self.notification_switch.build_notification()
45+ return self.notification_switch.get_notification()
46
47 def download_started(self, command):
48 """A download just started."""
49
50=== modified file 'ubuntuone/status/aggregator.py'
51--- ubuntuone/status/aggregator.py 2011-03-10 14:48:06 +0000
52+++ ubuntuone/status/aggregator.py 2011-03-14 18:40:16 +0000
53@@ -140,9 +140,12 @@
54
55 enabled = True
56
57- def build_notification(self):
58+ def __init__(self):
59+ self.toggleable_notification = ToggleableNotification(self)
60+
61+ def get_notification(self):
62 """Return a new notification instance."""
63- return ToggleableNotification(self)
64+ return self.toggleable_notification
65
66 def enable_notifications(self):
67 """Turn the switch on."""
68@@ -435,7 +438,7 @@
69
70 def _start(self):
71 """The first file was found, so start gathering."""
72- self.notification = self.status_aggregator.build_notification()
73+ self.notification = self.status_aggregator.get_notification()
74 self._change_state(FileDiscoveryGatheringState)
75
76 def _popup(self):
77@@ -486,7 +489,7 @@
78
79 def _timeout(self, result):
80 """Show the bubble."""
81- self.notification = self.status_aggregator.build_notification()
82+ self.notification = self.status_aggregator.get_notification()
83 text = self.status_aggregator.get_progress_message()
84 self.notification.send_notification(UBUNTUONE_TITLE, text)
85 self.restart()
86@@ -584,7 +587,7 @@
87
88 def show(self):
89 """Show the final status notification."""
90- self.notification = self.status_aggregator.build_notification()
91+ self.notification = self.status_aggregator.get_notification()
92 text = self.status_aggregator.get_final_status_message()
93 self.notification.send_notification(UBUNTUONE_TITLE, text)
94
95@@ -610,9 +613,9 @@
96 self.reset()
97 self.progress_bar = ProgressBar(clock=self.clock)
98
99- def build_notification(self):
100+ def get_notification(self):
101 """Create a new toggleable notification object."""
102- return self.notification_switch.build_notification()
103+ return self.notification_switch.get_notification()
104
105 # pylint: disable=W0201
106 def reset(self):
107@@ -771,7 +774,7 @@
108 def __init__(self, clock=reactor):
109 """Initialize this instance."""
110 self.aggregator = StatusAggregator(clock=clock)
111- self.notification = self.aggregator.build_notification()
112+ self.notification = self.aggregator.get_notification()
113 self.messaging = Messaging()
114 self.udf_message = None
115

Subscribers

People subscribed via source and target branches