119
117
self.assertEqual(entry.called, (('urgent', "foo"), {}))
120
class CheckUpdatesNoUpdatesTestCase(MainWindowTestCase):
121
"""Test the check_updates method when there are no updates."""
123
updates_available = False
125
@defer.inlineCallbacks
127
"""Set the different tests."""
128
yield super(CheckUpdatesNoUpdatesTestCase, self).setUp()
129
self.patch(gui.utils, 'are_updates_present',
130
lambda: defer.succeed(self.updates_available))
131
self.patch(gui.utils, 'perform_update',
132
lambda: defer.fail(ValueError()))
134
@defer.inlineCallbacks
135
def test_update_confirmation_dialog(self):
136
"""The confirmation dialog is not shown."""
137
yield self.ui.check_updates()
138
self.assertEqual(None, FakedDialog.args)
139
self.assertEqual(None, FakedDialog.kwargs)
141
@defer.inlineCallbacks
142
def test_perform_update(self):
143
"""The perform_update method is not called."""
144
yield self.ui.check_updates()
145
self.assertFalse(self._called)
148
class CheckUpdatesUserSaysNoTestCase(CheckUpdatesNoUpdatesTestCase):
149
"""Test check_updates when there are updates and user rejects them."""
151
updates_available = True
152
user_response = gui.QtGui.QMessageBox.No
154
@defer.inlineCallbacks
156
"""Set the different tests."""
157
yield super(CheckUpdatesUserSaysNoTestCase, self).setUp()
158
self.patch(FakedDialog, 'response', self.user_response)
160
@defer.inlineCallbacks
161
def test_update_confirmation_dialog(self):
162
"""The confirmation dialog is shown with correct params."""
163
yield self.ui.check_updates()
164
args = (self.ui, gui.UPDATE_TITLE, gui.UPDATE_SOFTWARE,
165
gui.QtGui.QMessageBox.Yes | gui.QtGui.QMessageBox.No,
166
gui.QtGui.QMessageBox.Yes)
167
self.assertEqual(args, FakedDialog.args)
168
self.assertEqual({}, FakedDialog.kwargs)
171
class CheckUpdatesUserSaysYesTestCase(CheckUpdatesUserSaysNoTestCase):
172
"""Test check_updates when there are updates and user accepts them."""
174
user_response = gui.QtGui.QMessageBox.Yes
176
@defer.inlineCallbacks
178
"""Set the different tests."""
179
self.updated = defer.Deferred()
180
yield super(CheckUpdatesUserSaysYesTestCase, self).setUp()
181
self.patch(gui.utils, 'perform_update',
182
lambda *a, **kw: self.updated.callback((a, kw)))
184
@defer.inlineCallbacks
185
def test_perform_update(self):
186
"""The perform_update method is called."""
187
yield self.ui.check_updates()
188
result = yield self.updated # perform_update will fire this deferred
190
self.assertEqual(result, ((), {}))
122
193
class AutoStartTestCase(MainWindowTestCase):
123
194
"""Test the add_to_autostart call."""
125
196
@defer.inlineCallbacks
127
198
# Be sure to patch add_to_autostart *before* class_ui creation occurs.
128
self.patch(gui, "add_to_autostart", self._set_called)
199
self.patch(gui.utils, "add_to_autostart", self._set_called)
129
200
yield super(AutoStartTestCase, self).setUp()
131
202
def test_add_to_autostart(self):