* added logging in daemon
[wifi-assistant] / package / test / unit / gui / popup_dialog_test.py
1 from gnome import gconf
2 from wifi_assistant.gui.popup_dialog import PopupDialog
3
4 import unittest
5 from unit.pie import *
6
7 ssid = 'Network Name'
8
9 class PopupDialogTest(unittest.TestCase):
10
11     def setUp(self):
12         self.parent_window = None
13         self.launch_callback = Mock()
14         
15         #given(self.launch_callback).call().willReturn(None)
16         self.launch_callback.replay()
17  
18         self.testee = PopupDialog(self.parent_window, self.launch_callback.call)
19
20
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)
25
26
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)
31
32
33     def test_cancellingDialogDoesntCallCallback(self):
34         self._makeRunDialogReturn(-1)
35         self.testee.show(ssid)
36         verify(self.launch_callback, never()).call()
37     
38     
39     def test_clickingYesButWithoutRemembering(self):
40         pass
41         # FIXME
42
43
44     def _makeRunDialogReturn(self, value):
45         class method():
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)
51         
52     
53 if __name__ == '__main__':
54     unittest.main()