1 from gnome import gconf
2 from wifi_assistant.gui.popup_dialog import PopupDialog
9 class PopupDialogTest(unittest.TestCase):
12 self.parent_window = None
13 self.launch_callback = Mock()
15 #given(self.launch_callback).call().willReturn(None)
16 self.launch_callback.replay()
18 self.testee = PopupDialog(self.parent_window, self.launch_callback.call)
21 def test_clickingYesButtonCallsCallback(self):
22 self._makeRunDialogReturn(PopupDialog.YES_BUTTON)
23 self.testee.show(ssid)
24 verify(self.launch_callback).call(ssid, True, True)
27 def test_clickingNoButtonCallsCallback(self):
28 self._makeRunDialogReturn(PopupDialog.NO_BUTTON)
29 self.testee.show(ssid)
30 verify(self.launch_callback).call(ssid, False, True)
33 def test_cancellingDialogDoesntCallCallback(self):
34 self._makeRunDialogReturn(-1)
35 self.testee.show(ssid)
36 verify(self.launch_callback, never()).call()
39 def test_clickingYesButWithoutRemembering(self):
44 def _makeRunDialogReturn(self, value):
46 def __init__(self, value_to_return):
47 self._value_to_return = value_to_return
48 def __call__(self, x):
49 return self._value_to_return
50 self.testee._runDialog = method(value)
53 if __name__ == '__main__':