97
117
self.patch(gui, "ForgottenPasswordController", FakeController)
98
118
self.patch(gui, "ResetPasswordController", FakeController)
99
119
self.patch(gui, "AreYouSure", FakeAreYouSure)
120
self.patch(gui, "LoadingOverlay", FakeOverlay)
100
121
super(MainWindowTestCase, self).setUp()
123
def test_critical(self):
124
"""Show a critical popup, but first hide the overlay."""
125
self.assertEqual(self.ui.overlay.hide_counter, 1)
126
self.patch(gui.QtGui.QMessageBox, "critical", self._set_called)
127
self.ui.critical("WORRY!")
128
self.assertEqual(self.ui.overlay.hide_counter, 2)
129
self.assertEqual(self._called, (('WORRY!',), {}))
131
def test_forgotten_password_controller_error(self):
132
"""When there is an error, it should hide the overlay."""
133
self.assertEqual(self.ui.overlay.hide_counter, 1)
134
controller = forgotten.ForgottenPasswordController()
135
controller.view = self.ui.forgotten
136
controller.on_password_reset_error("app_name",
137
{'errtype': 'ResetPasswordTokenError'})
138
self.assertEqual(self.ui.overlay.hide_counter, 2)
140
def test_overlay_connection_setup_account(self):
141
"""Make sure we don't lose connections to the overlay."""
142
self.assertEqual(self.ui.overlay.show_counter, 0)
143
# This test is different from the ones below.
144
# For some reason, click() doesn't trigger the connected
145
# slot, but clicked.emit() does. The reason is unknown.
146
self.ui.setup_account.ui.set_up_button.clicked.emit(False)
147
self.assertEqual(self.ui.overlay.show_counter, 1)
149
def test_overlay_connection_email_verification(self):
150
"""Make sure we don't lose connections to the overlay."""
151
self.assertEqual(self.ui.overlay.show_counter, 0)
152
self.ui.email_verification.next_button.click()
153
self.assertEqual(self.ui.overlay.show_counter, 1)
155
def test_overlay_connection_current_user(self):
156
"""Make sure we don't lose connections to the overlay."""
157
self.assertEqual(self.ui.overlay.show_counter, 0)
158
self.ui.current_user.ui.sign_in_button.click()
159
self.assertEqual(self.ui.overlay.show_counter, 1)
161
def test_overlay_connection_forgotten_password(self):
162
"""Make sure we don't lose connections to the overlay."""
163
self.assertEqual(self.ui.overlay.show_counter, 0)
164
self.ui.forgotten.ui.send_button.click()
165
self.assertEqual(self.ui.overlay.show_counter, 1)
167
def test_overlay_connection_reset_password(self):
168
"""Make sure we don't lose connections to the overlay."""
169
self.assertEqual(self.ui.overlay.show_counter, 0)
170
self.ui.reset_password.ui.reset_password_button.click()
171
self.assertEqual(self.ui.overlay.show_counter, 1)
173
def test_next_hides_overlay(self):
174
"""Make sure next() hides the overlay."""
176
# This is 2 because we hide it once on __init__()
177
# and then again on next()
178
self.assertEqual(self.ui.overlay.hide_counter, 2)
102
180
def test_done_calls_custom_close_callback(self):
103
181
"""When closing the window, close_callback is called."""
104
182
gui.AreYouSure.result = 0