浏览代码

Merge branch 'master' into 77/dev/beta_1.0/docker

Bastien Sevajol (Algoo) 8 年前
父节点
当前提交
e3db02e587
共有 4 个文件被更改,包括 22 次插入4 次删除
  1. 1 0
      tracim/migration/env.py
  2. 6 2
      tracim/tracim/config/middleware.py
  3. 2 1
      tracim/tracim/model/__init__.py
  4. 13 1
      tracim/tracim/tests/__init__.py

+ 1 - 0
tracim/migration/env.py 查看文件

65
             context.run_migrations()
65
             context.run_migrations()
66
     finally:
66
     finally:
67
         connection.close()
67
         connection.close()
68
+        engine.dispose()
68
 
69
 
69
 if context.is_offline_mode():
70
 if context.is_offline_mode():
70
     run_migrations_offline()
71
     run_migrations_offline()

+ 6 - 2
tracim/tracim/config/middleware.py 查看文件

3
 
3
 
4
 from tracim.config.app_cfg import base_config
4
 from tracim.config.app_cfg import base_config
5
 from tracim.config.environment import load_environment
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
 __all__ = ['make_app']
8
 __all__ = ['make_app']
10
 
9
 
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
     app = make_base_app(global_conf, full_stack=True, **app_conf)
40
     app = make_base_app(global_conf, full_stack=True, **app_conf)
37
     
41
     
38
     # Wrap your base TurboGears 2 application with custom middleware here
42
     # Wrap your base TurboGears 2 application with custom middleware here

+ 2 - 1
tracim/tracim/model/__init__.py 查看文件

85
 
85
 
86
 def init_model(engine):
86
 def init_model(engine):
87
     """Call me before using any of the tables or classes in the model."""
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
     # If you are using reflection to introspect your database and create
91
     # If you are using reflection to introspect your database and create
91
     # table objects for you, your tables must be defined and mapped inside
92
     # table objects for you, your tables must be defined and mapped inside

+ 13 - 1
tracim/tracim/tests/__init__.py 查看文件

63
 
63
 
64
 def load_app(name=application_name):
64
 def load_app(name=application_name):
65
     """Load the test application."""
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
 def setup_app(section_name=None):
77
 def setup_app(section_name=None):
156
             logger.debug(teardown_db, 'Exception while trying to remove sequence {}'.format(sequence.name))
164
             logger.debug(teardown_db, 'Exception while trying to remove sequence {}'.format(sequence.name))
157
 
165
 
158
     transaction.commit()
166
     transaction.commit()
167
+    connection.close()
159
     engine.dispose()
168
     engine.dispose()
160
 
169
 
161
 
170
 
249
         DBSession.close()
258
         DBSession.close()
250
         daemons.execute_in_thread('radicale', lambda: transaction.commit())
259
         daemons.execute_in_thread('radicale', lambda: transaction.commit())
251
         teardown_db()
260
         teardown_db()
261
+        transaction.commit()
262
+        DBSession.close_all()
263
+        config['tg.app_globals'].sa_engine.dispose()
252
 
264
 
253
 
265
 
254
 class TracimTestController(TestController):
266
 class TracimTestController(TestController):