Code

test fix
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Sun, 29 Feb 2004 00:41:51 +0000 (00:41 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Sun, 29 Feb 2004 00:41:51 +0000 (00:41 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2129 57a73879-2fb5-44c3-a270-3262357dd7e2

test/test_actions.py

index ebf39dfc5ed727e92e1d999aeca43e022adfcfa3..65a86f4beda5af4b176c52db9e97b2d676b2b504 100755 (executable)
@@ -6,7 +6,7 @@ from cgi import FieldStorage, MiniFieldStorage
 from roundup import hyperdb\r
 from roundup.date import Date, Interval\r
 from roundup.cgi.actions import *\r
-from roundup.cgi.exceptions import Redirect, Unauthorised\r
+from roundup.cgi.exceptions import Redirect, Unauthorised, SeriousError\r
 \r
 class MockNull:\r
     def __init__(self, **kwargs):\r
@@ -38,14 +38,20 @@ class ActionTestCase(unittest.TestCase):
         self.client.form = self.form\r
 \r
 class ShowActionTestCase(ActionTestCase):\r
-    def assertRaisesMessage(self, exception, callable, message, *args, **kwargs):\r
+    _nocheck = "don't compare exception values (the exception is enough)"\r
+    def assertRaisesMessage(self, exception, callable, message, *args,\r
+            **kwargs):\r
         try:\r
             callable(*args, **kwargs)\r
         except exception, msg:\r
+            if message is self._nocheck:\r
+                return\r
             self.assertEqual(str(msg), message)\r
         else:\r
-            if hasattr(excClass,'__name__'): excName = excClass.__name__\r
-            else: excName = str(excClass)\r
+            if hasattr(excClass,'__name__'):\r
+                excName = excClass.__name__\r
+            else:\r
+                excName = str(excClass)\r
             raise self.failureException, excName\r
 \r
     def testShowAction(self):\r
@@ -55,11 +61,18 @@ class ShowActionTestCase(ActionTestCase):
         self.assertRaises(ValueError, action.handle)\r
 \r
         self.form.value.append(MiniFieldStorage('@type', 'issue'))\r
-        self.assertRaisesMessage(Redirect, action.handle, 'BASE/issue')\r
+        self.assertRaisesMessage(SeriousError, action.handle, self._nocheck)\r
 \r
         self.form.value.append(MiniFieldStorage('@number', '1'))\r
         self.assertRaisesMessage(Redirect, action.handle, 'BASE/issue1')\r
 \r
+    def testShowActionNoType(self):\r
+        action = ShowAction(self.client)\r
+        self.assertRaises(ValueError, action.handle)\r
+        self.form.value.append(MiniFieldStorage('@number', '1'))\r
+        self.assertRaisesMessage(ValueError, action.handle,\r
+            'No type specified')\r
+\r
 class RetireActionTestCase(ActionTestCase):\r
     def testRetireAction(self):\r
         self.client.db.security.hasPermission = true\r