web/test/unittest_views_basecontrollers.py
branchstable
changeset 5377 84d14ddfae13
parent 5038 90493551b1eb
child 5385 b6e250dd7a7d
child 5389 809d3b5b3d31
equal deleted inserted replaced
5376:2c3f14bc2590 5377:84d14ddfae13
     3 :organization: Logilab
     3 :organization: Logilab
     4 :copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
     4 :copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
     6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
     7 """
     7 """
     8 import simplejson
     8 try:
       
     9     import json
       
    10 except ImportError:
       
    11     import simplejson as json
     9 
    12 
    10 from logilab.common.testlib import unittest_main, mock_object
    13 from logilab.common.testlib import unittest_main, mock_object
    11 
    14 
    12 from cubicweb import Binary, NoSelectableObject, ValidationError
    15 from cubicweb import Binary, NoSelectableObject, ValidationError
    13 from cubicweb.view import STRICT_DOCTYPE
    16 from cubicweb.view import STRICT_DOCTYPE
   548 
   551 
   549 #     def test_json_exec(self):
   552 #     def test_json_exec(self):
   550 #         rql = 'Any T,N WHERE T is Tag, T name N'
   553 #         rql = 'Any T,N WHERE T is Tag, T name N'
   551 #         ctrl = self.ctrl(self.request(mode='json', rql=rql, pageid='123'))
   554 #         ctrl = self.ctrl(self.request(mode='json', rql=rql, pageid='123'))
   552 #         self.assertEquals(ctrl.publish(),
   555 #         self.assertEquals(ctrl.publish(),
   553 #                           simplejson.dumps(self.execute(rql).rows))
   556 #                           json.dumps(self.execute(rql).rows))
   554 
   557 
   555     def test_remote_add_existing_tag(self):
   558     def test_remote_add_existing_tag(self):
   556         self.remote_call('tag_entity', self.john.eid, ['python'])
   559         self.remote_call('tag_entity', self.john.eid, ['python'])
   557         self.assertUnorderedIterableEquals([tname for tname, in self.execute('Any N WHERE T is Tag, T name N')],
   560         self.assertUnorderedIterableEquals([tname for tname, in self.execute('Any N WHERE T is Tag, T name N')],
   558                              ['python', 'cubicweb'])
   561                              ['python', 'cubicweb'])
   625 
   628 
   626 
   629 
   627     # silly tests
   630     # silly tests
   628     def test_external_resource(self):
   631     def test_external_resource(self):
   629         self.assertEquals(self.remote_call('external_resource', 'RSS_LOGO')[0],
   632         self.assertEquals(self.remote_call('external_resource', 'RSS_LOGO')[0],
   630                           simplejson.dumps(self.request().external_resource('RSS_LOGO')))
   633                           json.dumps(self.request().external_resource('RSS_LOGO')))
   631     def test_i18n(self):
   634     def test_i18n(self):
   632         self.assertEquals(self.remote_call('i18n', ['bimboom'])[0],
   635         self.assertEquals(self.remote_call('i18n', ['bimboom'])[0],
   633                           simplejson.dumps(['bimboom']))
   636                           json.dumps(['bimboom']))
   634 
   637 
   635     def test_format_date(self):
   638     def test_format_date(self):
   636         self.assertEquals(self.remote_call('format_date', '2007-01-01 12:00:00')[0],
   639         self.assertEquals(self.remote_call('format_date', '2007-01-01 12:00:00')[0],
   637                           simplejson.dumps('2007/01/01'))
   640                           json.dumps('2007/01/01'))
   638 
   641 
   639 
   642 
   640 
   643 
   641 
   644 
   642 if __name__ == '__main__':
   645 if __name__ == '__main__':