Ver código fonte

Merge branch 'master' of github.com:tracim/tracim

Come 7 anos atrás
pai
commit
f85f03a60f

+ 1 - 1
install/requirements.txt Ver arquivo

@@ -51,7 +51,7 @@ tgapp-resetpassword==0.1.8
51 51
 tgext.admin==0.6.4
52 52
 tgext.asyncjob==0.3.1
53 53
 tgext.crud==0.7.3
54
-tgext.pluggable==0.5.5
54
+tgext.pluggable==0.6.2
55 55
 transaction==1.4.4
56 56
 tw2.core==2.2.2
57 57
 tw2.forms==2.2.2.1

+ 1 - 0
tracim/migration/env.py Ver arquivo

@@ -65,6 +65,7 @@ def run_migrations_online():
65 65
             context.run_migrations()
66 66
     finally:
67 67
         connection.close()
68
+        engine.dispose()
68 69
 
69 70
 if context.is_offline_mode():
70 71
     run_migrations_offline()

+ 6 - 2
tracim/tracim/config/middleware.py Ver arquivo

@@ -3,8 +3,7 @@
3 3
 
4 4
 from tracim.config.app_cfg import base_config
5 5
 from tracim.config.environment import load_environment
6
-from tracim.lib.daemons import DaemonsManager
7
-from tracim.lib.daemons import RadicaleDaemon
6
+from sqlalchemy.pool import NullPool
8 7
 
9 8
 __all__ = ['make_app']
10 9
 
@@ -33,6 +32,11 @@ def make_app(global_conf, full_stack=True, **app_conf):
33 32
     
34 33
    
35 34
     """
35
+    # Configure NullPool for SQLAlchemy id we are in tests: unknown reason
36
+    # don't close it's connection during test and exceed postgresql limit.
37
+    if global_conf.get('test') == 'true':
38
+        global_conf['sqlalchemy.poolclass'] = NullPool
39
+
36 40
     app = make_base_app(global_conf, full_stack=True, **app_conf)
37 41
     
38 42
     # Wrap your base TurboGears 2 application with custom middleware here

+ 2 - 1
tracim/tracim/model/__init__.py Ver arquivo

@@ -85,7 +85,8 @@ metadata = DeclarativeBase.metadata
85 85
 
86 86
 def init_model(engine):
87 87
     """Call me before using any of the tables or classes in the model."""
88
-    DBSession.configure(bind=engine)
88
+    if not DBSession.registry.has():  # Prevent a SQLAlchemy warning
89
+        DBSession.configure(bind=engine)
89 90
 
90 91
     # If you are using reflection to introspect your database and create
91 92
     # table objects for you, your tables must be defined and mapped inside

+ 13 - 1
tracim/tracim/tests/__init__.py Ver arquivo

@@ -63,7 +63,15 @@ class TestApp(BaseTestApp):
63 63
 
64 64
 def load_app(name=application_name):
65 65
     """Load the test application."""
66
-    return TestApp(loadapp('config:test.ini#%s' % name, relative_to=getcwd()))
66
+    return TestApp(
67
+        loadapp(
68
+            'config:test.ini#%s' % name,
69
+            relative_to=getcwd(),
70
+            global_conf={
71
+                'test': 'true',
72
+            },
73
+        )
74
+    )
67 75
 
68 76
 
69 77
 def setup_app(section_name=None):
@@ -156,6 +164,7 @@ def teardown_db():
156 164
             logger.debug(teardown_db, 'Exception while trying to remove sequence {}'.format(sequence.name))
157 165
 
158 166
     transaction.commit()
167
+    connection.close()
159 168
     engine.dispose()
160 169
 
161 170
 
@@ -249,6 +258,9 @@ class TestController(object):
249 258
         DBSession.close()
250 259
         daemons.execute_in_thread('radicale', lambda: transaction.commit())
251 260
         teardown_db()
261
+        transaction.commit()
262
+        DBSession.close_all()
263
+        config['tg.app_globals'].sa_engine.dispose()
252 264
 
253 265
 
254 266
 class TracimTestController(TestController):