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( |
560 self.assertUnorderedIterableEquals( |
558 [tname for tname, in self.execute('Any N WHERE T is Tag, T name N')], |
561 [tname for tname, in self.execute('Any N WHERE T is Tag, T name N')], |
629 |
632 |
630 |
633 |
631 # silly tests |
634 # silly tests |
632 def test_external_resource(self): |
635 def test_external_resource(self): |
633 self.assertEquals(self.remote_call('external_resource', 'RSS_LOGO')[0], |
636 self.assertEquals(self.remote_call('external_resource', 'RSS_LOGO')[0], |
634 simplejson.dumps(self.request().external_resource('RSS_LOGO'))) |
637 json.dumps(self.request().external_resource('RSS_LOGO'))) |
635 def test_i18n(self): |
638 def test_i18n(self): |
636 self.assertEquals(self.remote_call('i18n', ['bimboom'])[0], |
639 self.assertEquals(self.remote_call('i18n', ['bimboom'])[0], |
637 simplejson.dumps(['bimboom'])) |
640 json.dumps(['bimboom'])) |
638 |
641 |
639 def test_format_date(self): |
642 def test_format_date(self): |
640 self.assertEquals(self.remote_call('format_date', '2007-01-01 12:00:00')[0], |
643 self.assertEquals(self.remote_call('format_date', '2007-01-01 12:00:00')[0], |
641 simplejson.dumps('2007/01/01')) |
644 json.dumps('2007/01/01')) |
642 |
645 |
643 |
646 |
644 |
647 |
645 |
648 |
646 if __name__ == '__main__': |
649 if __name__ == '__main__': |