server/test/unittest_undo.py
changeset 10788 416840faf119
parent 10365 21461f80f348
equal deleted inserted replaced
10787:34ada3b21eef 10788:416840faf119
    14 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    14 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    15 # details.
    15 # details.
    16 #
    16 #
    17 # You should have received a copy of the GNU Lesser General Public License along
    17 # You should have received a copy of the GNU Lesser General Public License along
    18 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
       
    19 
       
    20 from six import text_type
    19 
    21 
    20 from cubicweb import ValidationError
    22 from cubicweb import ValidationError
    21 from cubicweb.devtools.testlib import CubicWebTC
    23 from cubicweb.devtools.testlib import CubicWebTC
    22 import cubicweb.server.session
    24 import cubicweb.server.session
    23 from cubicweb.server.session import Connection as OldConnection
    25 from cubicweb.server.session import Connection as OldConnection
   253             self.assertUndoTransaction(cnx, txuuid, [
   255             self.assertUndoTransaction(cnx, txuuid, [
   254                 u"Can't restore relation in_group, object entity "
   256                 u"Can't restore relation in_group, object entity "
   255                 "%s doesn't exist anymore." % g.eid])
   257                 "%s doesn't exist anymore." % g.eid])
   256             with self.assertRaises(ValidationError) as cm:
   258             with self.assertRaises(ValidationError) as cm:
   257                 cnx.commit()
   259                 cnx.commit()
   258             cm.exception.translate(unicode)
   260             cm.exception.translate(text_type)
   259             self.assertEqual(cm.exception.entity, self.totoeid)
   261             self.assertEqual(cm.exception.entity, self.totoeid)
   260             self.assertEqual(cm.exception.errors,
   262             self.assertEqual(cm.exception.errors,
   261                               {'in_group-subject': u'at least one relation in_group is '
   263                               {'in_group-subject': u'at least one relation in_group is '
   262                                'required on CWUser (%s)' % self.totoeid})
   264                                'required on CWUser (%s)' % self.totoeid})
   263 
   265 
   459 class UndoExceptionInUnicode(CubicWebTC):
   461 class UndoExceptionInUnicode(CubicWebTC):
   460 
   462 
   461     # problem occurs in string manipulation for python < 2.6
   463     # problem occurs in string manipulation for python < 2.6
   462     def test___unicode__method(self):
   464     def test___unicode__method(self):
   463         u = _UndoException(u"voilĂ ")
   465         u = _UndoException(u"voilĂ ")
   464         self.assertIsInstance(unicode(u), unicode)
   466         self.assertIsInstance(text_type(u), text_type)
   465 
   467 
   466 
   468 
   467 if __name__ == '__main__':
   469 if __name__ == '__main__':
   468     from logilab.common.testlib import unittest_main
   470     from logilab.common.testlib import unittest_main
   469     unittest_main()
   471     unittest_main()