web/test/unittest_web.py
author sylvain.thenault@logilab.fr
Mon, 04 May 2009 13:36:31 +0200
branchtls-sprint
changeset 1646 88182252fd11
child 1977 606923dff11b
permissions -rw-r--r--
fix tests, cleanup
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1646
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
     1
from logilab.common.testlib import TestCase, unittest_main
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
     2
from cubicweb.web import ajax_replace_url as  arurl
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
     3
class AjaxReplaceUrlTC(TestCase):
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
     4
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
     5
    def test_ajax_replace_url(self):
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
     6
        # NOTE: for the simplest use cases, we could use doctest
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
     7
        self.assertEquals(arurl('foo', 'Person P'),
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
     8
                          "javascript: replacePageChunk('foo', 'Person%20P');")
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
     9
        self.assertEquals(arurl('foo', 'Person P', 'oneline'),
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    10
                          "javascript: replacePageChunk('foo', 'Person%20P', 'oneline');")
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    11
        self.assertEquals(arurl('foo', 'Person P', 'oneline', name='bar', age=12),
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    12
                          'javascript: replacePageChunk(\'foo\', \'Person%20P\', \'oneline\', {"age": 12, "name": "bar"});')
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    13
        self.assertEquals(arurl('foo', 'Person P', name='bar', age=12),
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    14
                          'javascript: replacePageChunk(\'foo\', \'Person%20P\', \'null\', {"age": 12, "name": "bar"});')
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    15
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    16
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    17
if __name__ == '__main__':
88182252fd11 fix tests, cleanup
sylvain.thenault@logilab.fr
parents:
diff changeset
    18
    unittest_main()