Skip to content

Commit c7924ca

Browse files
committed
don't read config from file, but from DB
1 parent 71526bb commit c7924ca

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

qiita_pet/handlers/cloud_handlers/file_transfer_handlers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from tornado.web import HTTPError, RequestHandler
44
from tornado.gen import coroutine
55

6-
from qiita_core.util import execute_as_transaction
6+
from qiita_core.util import execute_as_transaction, is_test_environment
77
from qiita_db.handlers.oauth2 import authenticate_oauth
88
from qiita_core.qiita_settings import qiita_config
99

@@ -93,8 +93,7 @@ def post(self):
9393
filepath = os.path.abspath(os.path.join(basedatadir, filepath))
9494

9595
# prevent overwriting existing files, except in test mode
96-
if os.path.exists(filepath) and \
97-
(not qiita_config.test_environment):
96+
if os.path.exists(filepath) and (not is_test_environment()):
9897
raise HTTPError(403, reason=(
9998
"The requested file is already "
10099
"present in Qiita's BASE_DATA_DIR!"))

qiita_pet/handlers/cloud_handlers/tests/test_file_transfer_handlers.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from qiita_db.handlers.tests.oauthbase import OauthTestingBase
77
import qiita_db as qdb
8-
from qiita_core.qiita_settings import qiita_config
8+
from qiita_db.sql_connection import TRN
99

1010

1111
class FetchFileFromCentralHandlerTests(OauthTestingBase):
@@ -72,10 +72,14 @@ def test_post(self):
7272
# check if error is raised, if file already exists
7373
with open(fp_source, 'rb') as fh:
7474
# we need to let qiita thinks for this test, to NOT be in test mode
75-
oldval = qiita_config.test_environment
76-
qiita_config.test_environment = False
75+
with TRN:
76+
TRN.add("UPDATE settings SET test = False")
77+
TRN.execute()
7778
obs = self.post_authed(endpoint, files={'bar/': fh})
78-
qiita_config.test_environment = oldval
79+
# reset test mode to true
80+
with TRN:
81+
TRN.add("UPDATE settings SET test = True")
82+
TRN.execute()
7983
self.assertIn("already present in Qiita's BASE_DATA_DIR!",
8084
obs.reason)
8185

0 commit comments

Comments
 (0)