server/test/unittest_postgres.py
changeset 10328 d7ff46d958f4
parent 9804 fe9ae959da08
child 10439 45e18b4a7466
child 10455 ad0615d4500d
--- a/server/test/unittest_postgres.py	Wed Apr 15 22:08:08 2015 +0200
+++ b/server/test/unittest_postgres.py	Mon Apr 06 21:46:52 2015 +0200
@@ -113,6 +113,24 @@
             self.assertEqual(datenaiss.tzinfo, None)
             self.assertEqual(datenaiss.utctimetuple()[:5], (1977, 6, 7, 2, 0))
 
+class PostgresLimitSizeTC(CubicWebTC):
+    configcls = PostgresApptestConfiguration
+
+    def test(self):
+        with self.admin_access.repo_cnx() as cnx:
+            def sql(string):
+                return cnx.system_sql(string).fetchone()[0]
+            yield self.assertEqual, sql("SELECT limit_size('<p>hello</p>', 'text/html', 20)"), \
+                '<p>hello</p>'
+            yield self.assertEqual, sql("SELECT limit_size('<p>hello</p>', 'text/html', 2)"), \
+                'he...'
+            yield self.assertEqual, sql("SELECT limit_size('<br/>hello', 'text/html', 2)"), \
+                'he...'
+            yield self.assertEqual, sql("SELECT limit_size('<span class=\"1\">he</span>llo', 'text/html', 2)"), \
+                'he...'
+            yield self.assertEqual, sql("SELECT limit_size('<span>a>b</span>', 'text/html', 2)"), \
+                'a>...'
+
 if __name__ == '__main__':
     from logilab.common.testlib import unittest_main
     unittest_main()