fixes for Bug #11199
[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 test_bug_11199_dialogTitleContainsVersion(self):
34         class checkVersionOnShow():
35             def __init__(self, version):
36                 self.version = version
37             def __call__(self, dialog):
38                 assert self.version in dialog.get_title()
39         
40         self.testee._runDialog = checkVersionOnShow(AboutDialog.VERSION)
41         self.testee.show()
42
43
44     def _makeRunDialogReturn(self, value):
45         class method():
46             def __init__(self, testee, value_to_return):
47                 self._value_to_return = value_to_return
48                 self._testee= testee
49             
50             def __call__(self, dialog):
51                 self._testee._responseCallback(dialog, self._value_to_return)
52
53         self.testee._runDialog = method(self.testee, value)
54         
55     
56 if __name__ == '__main__':
57     unittest.main()