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