comparison 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
comparison
equal deleted inserted replaced
4520:182d8c41a3aa 4521:abd2db0a159a
876 cl = self._make_client(depgrp, classname='iss', nodeid=None, 876 cl = self._make_client(depgrp, classname='iss', nodeid=None,
877 userid=mary, template='index') 877 userid=mary, template='index')
878 h = HTMLRequest(cl) 878 h = HTMLRequest(cl)
879 self.assertEqual([x.id for x in h.batch()],['1', '2', '3']) 879 self.assertEqual([x.id for x in h.batch()],['1', '2', '3'])
880 880
881 def testEditCSV(self):
882 form = dict(rows='id,name\n1,newkey')
883 cl = self._make_client(form, userid='1', classname='keyword')
884 cl.ok_message = []
885 actions.EditCSVAction(cl).handle()
886 self.assertEqual(cl.ok_message, ['Items edited OK'])
887 k = self.db.keyword.getnode('1')
888 self.assertEqual(k.name, 'newkey')
889 form = dict(rows=u'id,name\n1,\xe4\xf6\xfc'.encode('utf-8'))
890 cl = self._make_client(form, userid='1', classname='keyword')
891 cl.ok_message = []
892 actions.EditCSVAction(cl).handle()
893 self.assertEqual(cl.ok_message, ['Items edited OK'])
894 k = self.db.keyword.getnode('1')
895 self.assertEqual(k.name, u'\xe4\xf6\xfc'.encode('utf-8'))
896
881 def testRoles(self): 897 def testRoles(self):
882 cl = self._make_client({}) 898 cl = self._make_client({})
883 self.db.user.set('1', roles='aDmin, uSer') 899 self.db.user.set('1', roles='aDmin, uSer')
884 item = HTMLItem(cl, 'user', '1') 900 item = HTMLItem(cl, 'user', '1')
885 self.assert_(item.hasRole('Admin')) 901 self.assert_(item.hasRole('Admin'))

Roundup Issue Tracker: http://roundup-tracker.org/