Mercurial > p > roundup > code
diff test/test_cgi.py @ 4112:6441ffe588f7
fix bug introduced into CSV export and view (issue 2550529)
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 16 Mar 2009 04:16:43 +0000 |
| parents | 34434785f308 |
| children | 966592263fb8 |
line wrap: on
line diff
--- a/test/test_cgi.py Mon Mar 16 03:41:31 2009 +0000 +++ b/test/test_cgi.py Mon Mar 16 04:16:43 2009 +0000 @@ -10,7 +10,7 @@ # # $Id: test_cgi.py,v 1.36 2008-08-07 06:12:57 richard Exp $ -import unittest, os, shutil, errno, sys, difflib, cgi, re +import unittest, os, shutil, errno, sys, difflib, cgi, re, StringIO from roundup.cgi import client, actions, exceptions from roundup.cgi.exceptions import FormError @@ -18,6 +18,8 @@ from roundup.cgi.form_parser import FormParser from roundup import init, instance, password, hyperdb, date +from mocknull import MockNull + import db_test_base NEEDS_INSTANCE = 1 @@ -614,13 +616,13 @@ # SECURITY # # XXX test all default permissions - def _make_client(self, form, classname='user', nodeid='2', userid='2'): + def _make_client(self, form, classname='user', nodeid='1', userid='2'): cl = client.Client(self.instance, None, {'PATH_INFO':'/', 'REQUEST_METHOD':'POST'}, makeForm(form)) cl.classname = 'user' - cl.nodeid = '1' + cl.nodeid = nodeid cl.db = self.db - cl.userid = '2' + cl.userid = userid cl.language = ('en',) return cl @@ -646,6 +648,33 @@ self.failUnlessRaises(exceptions.Unauthorised, actions.EditItemAction(cl).handle) + def testCSVExport(self): + cl = self._make_client({'@columns': 'id,name'}, nodeid=None, + userid='1') + cl.classname = 'status' + output = StringIO.StringIO() + cl.request = MockNull() + cl.request.wfile = output + actions.ExportCSVAction(cl).handle() + self.assertEquals('id,name\r\n1,unread\r\n2,deferred\r\n3,chatting\r\n' + '4,need-eg\r\n5,in-progress\r\n6,testing\r\n7,done-cbb\r\n' + '8,resolved\r\n', + output.getvalue()) + + def testCSVExportFailPermission(self): + cl = self._make_client({'@columns': 'id,email,password'}, nodeid=None, + userid='2') + cl.classname = 'user' + output = StringIO.StringIO() + cl.request = MockNull() + cl.request.wfile = output + self.assertRaises(exceptions.Unauthorised, + actions.ExportCSVAction(cl).handle) + + +def test_suite(): + suite = unittest.TestSuite() + def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(FormTestCase))
