Mercurial > p > roundup > code
diff test/test_cgi.py @ 4521:abd2db0a159a
Fix StringIO issue2550713:
- io.StringIO in newer versions of python
returns unicode strings and expects a unicode string in the
constructor. Unfortunately csv doesn't handle unicode (yet). So we
need to use a BytesIO which gets the utf-8 string from the
web-interface. Compatibility for old versions by using
Stringio.Stringio for emulating a io.BytesIO also works.
- We didn't have a regression test for the EditCSVAction
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Fri, 15 Jul 2011 12:36:47 +0000 |
| parents | 693c75d56ebe |
| children | 6e3e4f24c753 |
line wrap: on
line diff
--- a/test/test_cgi.py Fri Jul 15 10:03:37 2011 +0000 +++ b/test/test_cgi.py Fri Jul 15 12:36:47 2011 +0000 @@ -878,6 +878,22 @@ h = HTMLRequest(cl) self.assertEqual([x.id for x in h.batch()],['1', '2', '3']) + def testEditCSV(self): + form = dict(rows='id,name\n1,newkey') + cl = self._make_client(form, userid='1', classname='keyword') + cl.ok_message = [] + actions.EditCSVAction(cl).handle() + self.assertEqual(cl.ok_message, ['Items edited OK']) + k = self.db.keyword.getnode('1') + self.assertEqual(k.name, 'newkey') + form = dict(rows=u'id,name\n1,\xe4\xf6\xfc'.encode('utf-8')) + cl = self._make_client(form, userid='1', classname='keyword') + cl.ok_message = [] + actions.EditCSVAction(cl).handle() + self.assertEqual(cl.ok_message, ['Items edited OK']) + k = self.db.keyword.getnode('1') + self.assertEqual(k.name, u'\xe4\xf6\xfc'.encode('utf-8')) + def testRoles(self): cl = self._make_client({}) self.db.user.set('1', roles='aDmin, uSer')
