major rewrite
[wifi-assistant] / package / test / unit / gui / about_dialog_test.py
diff --git a/package/test/unit/gui/about_dialog_test.py b/package/test/unit/gui/about_dialog_test.py
new file mode 100644 (file)
index 0000000..a0966f6
--- /dev/null
@@ -0,0 +1,43 @@
+from gnome import gconf
+from wifi_assistant.gui.about_dialog import AboutDialog
+
+import unittest
+from unit.pie import *
+
+class AboutDialogTest(unittest.TestCase):
+
+    def setUp(self):
+        self.launcher = Mock()
+        self.launcher.replay()
+        self.testee = AboutDialog(self.launcher, None)
+
+
+    def test_bugButtonCallsLauncher(self):
+        self._makeRunDialogReturn(AboutDialog.BUG_BUTTON)
+        self.testee.show()
+        verify(self.launcher).openUrl(AboutDialog.BUG_URL)
+
+
+    def test_closeButtonDoesntCallLauncher(self):
+        self._makeRunDialogReturn(AboutDialog.CLOSE_BUTTON)
+        self.testee.show()
+        verify(self.launcher, never()).openUrl()
+
+
+    def test_donateButtonCallsLauncher(self):
+        self._makeRunDialogReturn(AboutDialog.DONATE_BUTTON)
+        self.testee.show()
+        verify(self.launcher).openUrl(AboutDialog.DONATE_URL)
+
+
+    def _makeRunDialogReturn(self, value):
+        class method():
+            def __init__(self, value_to_return):
+                self._value_to_return = value_to_return
+            def __call__(self, x):
+                return self._value_to_return
+        self.testee._runDialog = method(value)
+        
+    
+if __name__ == '__main__':
+    unittest.main()