refactoring main GUI application to
[wifi-assistant] / package / test / unit / gui / test_AboutDialog.py
1 from gnome import gconf
2 from wifi_assistant.daemon import Daemon
3 from wifi_assistant.gui.about_dialog import AboutDialog
4
5 import unittest
6 from unit.pie import *
7
8
9
10 class AboutDialogTest(unittest.TestCase):
11
12     def setUp(self):
13         self.launcher = Mock()
14         self.launcher.replay()
15         self.testee = AboutDialog(self.launcher, None)
16
17
18     def test_bugButtonCallsLauncher(self):
19         self._makeRunDialogReturn(AboutDialog.BUG_BUTTON)
20         self.testee.show()
21         verify(self.launcher).openUrl(AboutDialog.BUG_URL)
22
23
24     def test_closeButtonDoesntCallLauncher(self):
25         self._makeRunDialogReturn(AboutDialog.CLOSE_BUTTON)
26         self.testee.show()
27         verify(self.launcher, never()).openUrl()
28
29
30     def test_donateButtonCallsLauncher(self):
31         self._makeRunDialogReturn(AboutDialog.DONATE_BUTTON)
32         self.testee.show()
33         verify(self.launcher).openUrl(AboutDialog.DONATE_URL)
34
35
36     def _makeRunDialogReturn(self, value):
37         class method():
38             def __init__(self, value_to_return):
39                 self._value_to_return = value_to_return
40             def __call__(self, x):
41                 return self._value_to_return
42         self.testee._runDialog = method(value)
43     
44 if __name__ == '__main__':
45     unittest.main()
46