def tearDown(self): utils.env.teardown() # TODO: figure out why this is necessary here, but unnecessary in all # of the tests in `tests/test_unit_*.py`. Without this, the session # continues to return values even if the underlying database is deleted # (as in `shared_teardown`). db_session.remove()
def teardown(): db_session.remove() try: shutil.rmtree(config.SECUREDROP_DATA_ROOT) except OSError as exc: if 'No such file or directory' not in exc: raise
def tearDown(self): common.shared_teardown() # TODO: figure out why this is necessary here, but unnecessary in all # of the tests in `tests/test_unit_*.py`. Without this, the session # continues to return values even if the underlying database is deleted # (as in `shared_teardown`). db_session.remove()
def test_reset(self): test_journalist, _ = utils.db_helper.init_journalist() user_should_be_gone = test_journalist.username return_value = manage.reset(args=None) self.assertEqual(return_value, 0) assert os.path.exists(config.DATABASE_FILE) assert os.path.exists(config.STORE_DIR) # Verify journalist user present in the database is gone db_session.remove() # Close session and get a session on the new db with self.assertRaises(NoResultFound): Journalist.query.filter_by(username=user_should_be_gone).one()
def teardown(): # make sure threads launched by tests complete before # teardown, otherwise they may fail because resources # they need disappear for t in threading.enumerate(): if t.is_alive() and not isinstance(t, threading._MainThread): t.join() db_session.remove() try: shutil.rmtree(config.SECUREDROP_DATA_ROOT) assert not os.path.exists(config.SECUREDROP_DATA_ROOT) # safeguard for #844 except OSError as exc: if 'No such file or directory' not in exc: raise
def teardown(): # make sure threads launched by tests complete before # teardown, otherwise they may fail because resources # they need disappear for t in threading.enumerate(): if t.is_alive() and not isinstance(t, threading._MainThread): t.join() db_session.remove() shutil.rmtree(config.TEMP_DIR) try: shutil.rmtree(config.SECUREDROP_DATA_ROOT) assert not os.path.exists(config.SECUREDROP_DATA_ROOT) # safeguard for #844 except OSError as exc: if 'No such file or directory' not in exc: raise
def teardown(): # make sure threads launched by tests complete before # teardown, otherwise they may fail because resources # they need disappear for t in threading.enumerate(): if t.is_alive() and not isinstance(t, threading._MainThread): t.join() db_session.remove() try: shutil.rmtree(config.SECUREDROP_DATA_ROOT) except OSError as exc: os.system("find " + config.SECUREDROP_DATA_ROOT) # REMOVE ME, see #844 if 'No such file or directory' not in exc: raise except: os.system("find " + config.SECUREDROP_DATA_ROOT) # REMOVE ME, see #844 raise
def shutdown_session(_=None): ''' Shut down session route ''' db_session.remove()
def login(): """routing login """ if request.method == 'GET': return "TODO ログイン画面を表示" elif request.method == 'POST': return "TODO ログインし、本棚一覧にリダイレクト" else: return "TODO エラーハンドリング" @app.route('/logout', methods=['GET', 'POST']) def logout(): """routing logout """ if request.method == 'GET': return "TODO ログアウト画面を表示" elif request.method == 'POST': return "TODO ログアウトし、ログイン前トップ画面にリダイレクト" else: return "TODO エラーハンドリング" @app.errorhandler(404) def page_not_found(error): return render_template('404.html'), 404 @app.teardown_appcontext def shutdown_session(exception=None) db_session.remove()
def shutdown_session(exception=None): """Automatically remove database sessions at the end of the request, or when the application shuts down""" db_session.remove()
def shutdown_db(response): db_session.remove() return response
def tearDown(self): utils.env.teardown() db_session.remove()
def after_return(self, status, retval, task_id, args, kwargs, einfo): logger.debug("Removing db_session reference and task lock for %s" % self.name) db_session.remove() self.release_lock()
def shutdown_session(exception=None): """Close database session after each request""" db_session.remove()
def worker_bonus(self, chosen_hit, auto, amount, reason='', assignment_ids=None): ''' Bonus worker ''' if self.config.has_option('Shell Parameters', 'bonus_message'): reason = self.config.get('Shell Parameters', 'bonus_message') while not reason: user_input = raw_input("Type the reason for the bonus. Workers " "will see this message: ") reason = user_input # Bonus already-bonused workers if the user explicitly lists their # assignment IDs override_status = True if chosen_hit: override_status = False workers = self.amt_services.get_workers("Approved", chosen_hit) if not workers: print "No approved workers for HIT", chosen_hit return print 'bonusing workers for HIT', chosen_hit elif len(assignment_ids) == 1: workers = [self.amt_services.get_worker(assignment_ids[0])] if not workers: print "No submissions found for requested assignment ID" return else: workers = self.amt_services.get_workers("Approved") if not workers: print "No approved workers found." return workers = [worker for worker in workers if \ worker['assignmentId'] in assignment_ids] for worker in workers: assignment_id = worker['assignmentId'] try: init_db() part = Participant.query.\ filter(Participant.assignmentid == assignment_id).\ filter(Participant.workerid == worker['workerId']).\ filter(Participant.endhit != None).\ one() if auto: amount = part.bonus status = part.status if amount <= 0: print "bonus amount <=$0, no bonus given for assignment", assignment_id elif status == 7 and not override_status: print "bonus already awarded for assignment", assignment_id else: success = self.amt_services.bonus_worker(assignment_id, amount, reason) if success: print "gave bonus of $" + str(amount) + " for assignment " + \ assignment_id part.status = 7 db_session.add(part) db_session.commit() db_session.remove() else: print "*** failed to bonus assignment", assignment_id except: print "*** failed to bonus assignment", assignment_id
def remove_db_session(response): db_session.remove() return response
def shutdown_session(exception=None): db_session.remove()
def after_return(self, *args, **kwargs): db_session.remove()