File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
qiita_pet/handlers/cloud_handlers Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 3
3
from tornado .web import HTTPError , RequestHandler
4
4
from tornado .gen import coroutine
5
5
6
- from qiita_core .util import execute_as_transaction
6
+ from qiita_core .util import execute_as_transaction , is_test_environment
7
7
from qiita_db .handlers .oauth2 import authenticate_oauth
8
8
from qiita_core .qiita_settings import qiita_config
9
9
@@ -93,8 +93,7 @@ def post(self):
93
93
filepath = os .path .abspath (os .path .join (basedatadir , filepath ))
94
94
95
95
# 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 ()):
98
97
raise HTTPError (403 , reason = (
99
98
"The requested file is already "
100
99
"present in Qiita's BASE_DATA_DIR!" ))
Original file line number Diff line number Diff line change 5
5
6
6
from qiita_db .handlers .tests .oauthbase import OauthTestingBase
7
7
import qiita_db as qdb
8
- from qiita_core . qiita_settings import qiita_config
8
+ from qiita_db . sql_connection import TRN
9
9
10
10
11
11
class FetchFileFromCentralHandlerTests (OauthTestingBase ):
@@ -72,10 +72,14 @@ def test_post(self):
72
72
# check if error is raised, if file already exists
73
73
with open (fp_source , 'rb' ) as fh :
74
74
# 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 ()
77
78
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 ()
79
83
self .assertIn ("already present in Qiita's BASE_DATA_DIR!" ,
80
84
obs .reason )
81
85
You can’t perform that action at this time.
0 commit comments