server/test/unittest_postgres.py
changeset 10522 1660a0fa4f43
parent 10470 374a789c8f8d
parent 10455 ad0615d4500d
child 10609 e2d8e81bfe68
--- a/server/test/unittest_postgres.py	Wed Jul 08 09:37:06 2015 +0200
+++ b/server/test/unittest_postgres.py	Thu Jul 09 16:43:56 2015 +0200
@@ -38,8 +38,16 @@
     stoppgcluster(__file__)
 
 
+class PostgresTimeoutConfiguration(PostgresApptestConfiguration):
+    def __init__(self, *args, **kwargs):
+        self.default_sources = PostgresApptestConfiguration.default_sources.copy()
+        self.default_sources['system'] = PostgresApptestConfiguration.default_sources['system'].copy()
+        self.default_sources['system']['db-statement-timeout'] = 200
+        super(PostgresTimeoutConfiguration, self).__init__(*args, **kwargs)
+
+
 class PostgresFTITC(CubicWebTC):
-    configcls = PostgresApptestConfiguration
+    configcls = PostgresTimeoutConfiguration
 
     def test_eid_range(self):
         # concurrent allocation of eid ranges
@@ -134,6 +142,12 @@
                         {'type-subject-value': u'"nogood"',
                          'type-subject-choices': u'"todo", "a", "b", "T", "lalala"'})
 
+    def test_statement_timeout(self):
+        with self.admin_access.repo_cnx() as cnx:
+            cnx.system_sql('select pg_sleep(0.1)')
+            with self.assertRaises(Exception):
+                cnx.system_sql('select pg_sleep(0.3)')
+
 
 class PostgresLimitSizeTC(CubicWebTC):
     configcls = PostgresApptestConfiguration