web/test/unittest_web.py
author Nicolas Chauvat <nicolas.chauvat@logilab.fr>
Tue, 28 Jul 2009 18:44:19 +0200
changeset 2532 f7ca29d75183
parent 1977 606923dff11b
child 2643 9976f511003b
permissions -rw-r--r--
[cleanup] improve dialog message consistency
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1646
diff changeset
     1
"""
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1646
diff changeset
     2
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1646
diff changeset
     3
:organization: Logilab
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1646
diff changeset
     4
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1646
diff changeset
     5
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1646
diff changeset
     6
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1646
diff changeset
     7
"""
1646
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
     8
from logilab.common.testlib import TestCase, unittest_main
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
     9
from cubicweb.web import ajax_replace_url as  arurl
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    10
class AjaxReplaceUrlTC(TestCase):
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    11
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    12
    def test_ajax_replace_url(self):
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    13
        # NOTE: for the simplest use cases, we could use doctest
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    14
        self.assertEquals(arurl('foo', 'Person P'),
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    15
                          "javascript: replacePageChunk('foo', 'Person%20P');")
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    16
        self.assertEquals(arurl('foo', 'Person P', 'oneline'),
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    17
                          "javascript: replacePageChunk('foo', 'Person%20P', 'oneline');")
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    18
        self.assertEquals(arurl('foo', 'Person P', 'oneline', name='bar', age=12),
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    19
                          'javascript: replacePageChunk(\'foo\', \'Person%20P\', \'oneline\', {"age": 12, "name": "bar"});')
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    20
        self.assertEquals(arurl('foo', 'Person P', name='bar', age=12),
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    21
                          'javascript: replacePageChunk(\'foo\', \'Person%20P\', \'null\', {"age": 12, "name": "bar"});')
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    22
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    23
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    24
if __name__ == '__main__':
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    25
    unittest_main()