Browse Source

fix filedepot initialization

Guénaël Muller 7 years ago
parent
commit
6e552eca67
2 changed files with 20 additions and 1 deletions
  1. 13 1
      tracim/config.py
  2. 7 0
      tracim/tests/__init__.py

+ 13 - 1
tracim/config.py View File

@@ -1,6 +1,7 @@
1 1
 from paste.deploy.converters import asbool
2 2
 from urllib.parse import urlparse
3 3
 from tracim.logger import logger
4
+from depot.manager import DepotManager
4 5
 
5 6
 from pyramid.request import Request
6 7
 
@@ -8,7 +9,9 @@ from pyramid.request import Request
8 9
 class RequestWithCFG(Request):
9 10
 
10 11
     def config(self):
11
-        return CFG(self.registry.settings)
12
+        cfg = CFG(self.registry.settings)
13
+        cfg.configure_filedepot()
14
+        return cfg
12 15
 
13 16
 
14 17
 
@@ -416,6 +419,15 @@ class CFG(object):
416 419
         #     self.RADICALE_CLIENT_BASE_URL_PREFIX,
417 420
         # )
418 421
 
422
+    def configure_filedepot(self):
423
+        depot_storage_name = self.DEPOT_STORAGE_NAME
424
+        depot_storage_path = self.DEPOT_STORAGE_DIR
425
+        depot_storage_settings = {'depot.storage_path': depot_storage_path}
426
+        DepotManager.configure(
427
+            depot_storage_name,
428
+            depot_storage_settings,
429
+        )
430
+
419 431
     class CST(object):
420 432
         ASYNC = 'ASYNC'
421 433
         SYNC = 'SYNC'

+ 7 - 0
tracim/tests/__init__.py View File

@@ -1,5 +1,6 @@
1 1
 import unittest
2 2
 import transaction
3
+from depot.manager import DepotManager
3 4
 from pyramid import testing
4 5
 
5 6
 from tracim.models.data import Workspace
@@ -9,6 +10,7 @@ from tracim.fixtures import FixturesLoader
9 10
 from tracim.fixtures.users_and_groups import Base as BaseFixture
10 11
 from tracim.config import CFG
11 12
 
13
+
12 14
 class BaseTest(unittest.TestCase):
13 15
     """
14 16
     Pyramid default test.
@@ -24,6 +26,11 @@ class BaseTest(unittest.TestCase):
24 26
 
25 27
         })
26 28
         self.config.include('tracim.models')
29
+        DepotManager._clear()
30
+        DepotManager.configure(
31
+            'test',
32
+             { 'depot.backend' : 'depot.io.memory.MemoryFileStorage' },
33
+        )
27 34
         settings = self.config.get_settings()
28 35
 
29 36
         from tracim.models import (