165
165
self.assertIn('domain_label', dialog.ui.called)
166
166
self.assertIn(('setText', domain), dialog.ui.called['domain_label'])
168
def test_is_error(self):
168
def test_retry(self):
169
169
"""Test that we do set the error label correctly."""
170
dialog = proxy_dialog.ProxyCredsDialog(is_error=False)
170
dialog = proxy_dialog.ProxyCredsDialog(retry=False)
171
171
self.assertIn('error_label', dialog.ui.called)
172
172
self.assertIn(('setVisible', False), dialog.ui.called['error_label'])
174
def test_is_not_error(self):
174
def test_is_not_retry(self):
175
175
"""Test that we do set the error label correctly."""
176
dialog = proxy_dialog.ProxyCredsDialog(is_error=True)
176
dialog = proxy_dialog.ProxyCredsDialog(retry=True)
177
177
self.assertIn('error_label', dialog.ui.called)
178
178
self.assertIn(('setVisible', True), dialog.ui.called['error_label'])
233
233
set_creds_cb = lambda: defer.succeed(True)
234
234
result_number = proxy_dialog.CREDS_ACQUIRED
235
235
self.assert_save_button(set_creds_cb, result_number)
238
class FakeArgs(object):
239
"""Some fake args."""
241
def __init__(self, domain='', retry=False):
242
"""Create a new instance."""
247
class MainTest(TestCase):
248
"""Test the main method."""
250
@defer.inlineCallbacks
252
"""Set the different tests."""
253
yield super(MainTest, self).setUp()
256
self.args = FakeArgs(domain='domain', retry=False)
257
self.patch(proxy_dialog, 'parse_args', lambda: self.args)
260
self.patch(proxy_dialog.ProxyCredsDialog, 'exec_', lambda x:
262
self.exit_code = None
265
"""Fake the sys.exit."""
266
self.called.append(('exit', code))
267
self.exit_code = code
269
self.patch(proxy_dialog.sys, 'exit', fake_exit)
271
def fake_application(args):
272
"""Fake a QApplication."""
273
self.called.append(('QApplication', args))
275
self.patch(proxy_dialog, 'QApplication', fake_application)
278
"""Test the main method."""
280
self.assertIn('QApplication', self.called[0])
281
self.assertIn(('exit', self.return_code), self.called)