# HG changeset patch
# User sylvain.thenault@logilab.fr
# Date 1241436991 -7200
# Node ID 88182252fd115d1fed5d4ec27bf1ae26794af87b
# Parent 374586978230f1f5a51badf5bac5cbd533c7c105
fix tests, cleanup
diff -r 374586978230 -r 88182252fd11 common/test/unittest_uilib.py
--- a/common/test/unittest_uilib.py Mon May 04 13:36:01 2009 +0200
+++ b/common/test/unittest_uilib.py Mon May 04 13:36:31 2009 +0200
@@ -21,7 +21,7 @@
for text, expected in data:
got = uilib.remove_html_tags(text)
self.assertEquals(got, expected)
-
+
def test_fallback_safe_cut(self):
self.assertEquals(uilib.fallback_safe_cut(u'ab cd', 4), u'ab c...')
self.assertEquals(uilib.fallback_safe_cut(u'ab cd', 5), u'ab cd')
@@ -29,7 +29,7 @@
self.assertEquals(uilib.fallback_safe_cut(u'ab &d ef', 5), u'ab &d...')
self.assertEquals(uilib.fallback_safe_cut(u'ab ìd', 4), u'ab ì...')
self.assertEquals(uilib.fallback_safe_cut(u'& &d ef', 4), u'& &d...')
-
+
def test_lxml_safe_cut(self):
self.assertEquals(uilib.safe_cut(u'aaa
aaad
ef', 4), u'aaa
a...
')
self.assertEquals(uilib.safe_cut(u'aaaaaad
ef', 7), u'aaa
aaad
...')
@@ -75,18 +75,6 @@
got = uilib.text_cut(text, 30)
self.assertEquals(got, expected)
- def test_ajax_replace_url(self):
- # NOTE: for the simplest use cases, we could use doctest
- arurl = uilib.ajax_replace_url
- self.assertEquals(arurl('foo', 'Person P'),
- "javascript: replacePageChunk('foo', 'Person%20P');")
- self.assertEquals(arurl('foo', 'Person P', 'oneline'),
- "javascript: replacePageChunk('foo', 'Person%20P', 'oneline');")
- self.assertEquals(arurl('foo', 'Person P', 'oneline', name='bar', age=12),
- 'javascript: replacePageChunk(\'foo\', \'Person%20P\', \'oneline\', {"age": 12, "name": "bar"});')
- self.assertEquals(arurl('foo', 'Person P', name='bar', age=12),
- 'javascript: replacePageChunk(\'foo\', \'Person%20P\', \'null\', {"age": 12, "name": "bar"});')
-
tree = ('root', (
('child_1_1', (
('child_2_1', ()), ('child_2_2', (
@@ -116,18 +104,18 @@
for child in tuple[1]:
n.append(make_tree(child))
return n
-
+
class UIlibHTMLGenerationTC(TestCase):
""" a basic tree node, caracterised by an id"""
def setUp(self):
- """ called before each test from this class """
+ """ called before each test from this class """
self.o = make_tree(tree)
def test_generated_html(self):
s = uilib.render_HTML_tree(self.o, selected_node="child_2_2")
self.assertTextEqual(s, generated_html)
-
-
+
+
if __name__ == '__main__':
unittest_main()
diff -r 374586978230 -r 88182252fd11 common/uilib.py
--- a/common/uilib.py Mon May 04 13:36:01 2009 +0200
+++ b/common/uilib.py Mon May 04 13:36:31 2009 +0200
@@ -10,9 +10,7 @@
__docformat__ = "restructuredtext en"
import csv
-import decimal
import re
-from datetime import datetime, date, timedelta
from urllib import quote as urlquote
from StringIO import StringIO
diff -r 374586978230 -r 88182252fd11 web/test/unittest_web.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/test/unittest_web.py Mon May 04 13:36:31 2009 +0200
@@ -0,0 +1,18 @@
+from logilab.common.testlib import TestCase, unittest_main
+from cubicweb.web import ajax_replace_url as arurl
+class AjaxReplaceUrlTC(TestCase):
+
+ def test_ajax_replace_url(self):
+ # NOTE: for the simplest use cases, we could use doctest
+ self.assertEquals(arurl('foo', 'Person P'),
+ "javascript: replacePageChunk('foo', 'Person%20P');")
+ self.assertEquals(arurl('foo', 'Person P', 'oneline'),
+ "javascript: replacePageChunk('foo', 'Person%20P', 'oneline');")
+ self.assertEquals(arurl('foo', 'Person P', 'oneline', name='bar', age=12),
+ 'javascript: replacePageChunk(\'foo\', \'Person%20P\', \'oneline\', {"age": 12, "name": "bar"});')
+ self.assertEquals(arurl('foo', 'Person P', name='bar', age=12),
+ 'javascript: replacePageChunk(\'foo\', \'Person%20P\', \'null\', {"age": 12, "name": "bar"});')
+
+
+if __name__ == '__main__':
+ unittest_main()