def test_init_db(self): init_db() table_names = self.inspector.get_table_names() self.assertItemsEqual( ["host_meta", "deploy_meta", "user_meta", "ssh_permission_meta"], table_names )
def main(): init_db() application = tornado.web.Application( URL_PATTERNS, **TORNADO_SETTINGS ) application.listen(8888, address=LISTEN_ADDR) tornado.ioloop.IOLoop.current().start()
def cron_tasks(): init_db() schedule.every(SCHEDULER_JOB_PERIOD).minutes.do(cron_get_host_status) schedule.every(SCHEDULER_JOB_PERIOD).minutes.do( cron_get_host_docker_status ) schedule.every(SCHEDULER_JOB_PERIOD).minutes.do( cron_get_host_process_status ) while schedule.run_pending() is None: time.sleep(1)
def fixed_func(self, *args, **kwargs): init_db() connection = engine.connect() transaction = connection.begin() session = scoped_session(db_session) fixed_args = tuple(list(args) + [session]) try: func(self, *fixed_args, **kwargs) finally: session.remove() session.close() transaction.rollback() connection.close()
def test_drop_db(self): init_db() drop_db() table_names = self.inspector.get_table_names() self.assertListEqual([], table_names)