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 33from tornado .web import HTTPError , RequestHandler
44from 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
77from qiita_db .handlers .oauth2 import authenticate_oauth
88from 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!" ))
Original file line number Diff line number Diff line change 55
66from qiita_db .handlers .tests .oauthbase import OauthTestingBase
77import qiita_db as qdb
8- from qiita_core . qiita_settings import qiita_config
8+ from qiita_db . sql_connection import TRN
99
1010
1111class 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
You can’t perform that action at this time.
0 commit comments