1646
|
1 |
from logilab.common.testlib import TestCase, unittest_main |
|
2 |
from cubicweb.web import ajax_replace_url as arurl |
|
3 |
class AjaxReplaceUrlTC(TestCase): |
|
4 |
|
|
5 |
def test_ajax_replace_url(self): |
|
6 |
# NOTE: for the simplest use cases, we could use doctest |
|
7 |
self.assertEquals(arurl('foo', 'Person P'), |
|
8 |
"javascript: replacePageChunk('foo', 'Person%20P');") |
|
9 |
self.assertEquals(arurl('foo', 'Person P', 'oneline'), |
|
10 |
"javascript: replacePageChunk('foo', 'Person%20P', 'oneline');") |
|
11 |
self.assertEquals(arurl('foo', 'Person P', 'oneline', name='bar', age=12), |
|
12 |
'javascript: replacePageChunk(\'foo\', \'Person%20P\', \'oneline\', {"age": 12, "name": "bar"});') |
|
13 |
self.assertEquals(arurl('foo', 'Person P', name='bar', age=12), |
|
14 |
'javascript: replacePageChunk(\'foo\', \'Person%20P\', \'null\', {"age": 12, "name": "bar"});') |
|
15 |
|
|
16 |
|
|
17 |
if __name__ == '__main__': |
|
18 |
unittest_main() |