def setUp(self): conf.load_test_config() self.app, self.appbuilder = application.create_app(testing=True) self.app.config['WTF_CSRF_ENABLED'] = False self.client = self.app.test_client() self.session = Session() self.login()
def setUp(self): conf.load_test_config() self.app, self.appbuilder = application.create_app(testing=True) self.app.config['WTF_CSRF_ENABLED'] = False self.client = self.app.test_client() self.session = Session() self.login()
def setUp(self): conf.load_test_config() # Create a custom logging configuration logging_config = copy.deepcopy(DEFAULT_LOGGING_CONFIG) current_dir = os.path.dirname(os.path.abspath(__file__)) logging_config['handlers']['task']['base_log_folder'] = os.path.normpath( os.path.join(current_dir, 'test_logs')) logging_config['handlers']['task']['filename_template'] = \ '{{ ti.dag_id }}/{{ ti.task_id }}/' \ '{{ ts | replace(":", ".") }}/{{ try_number }}.log' # Write the custom logging configuration to a file self.settings_folder = tempfile.mkdtemp() settings_file = os.path.join(self.settings_folder, "airflow_local_settings.py") new_logging_file = "LOGGING_CONFIG = {}".format(logging_config) with open(settings_file, 'w') as handle: handle.writelines(new_logging_file) sys.path.append(self.settings_folder) conf.set('core', 'logging_config_class', 'airflow_local_settings.LOGGING_CONFIG') self.app, self.appbuilder = application.create_app(testing=True) self.app.config['WTF_CSRF_ENABLED'] = False self.client = self.app.test_client() self.login() self.session = Session() from airflow.www_rbac.views import dagbag dag = DAG(self.DAG_ID, start_date=self.DEFAULT_DATE) task = DummyOperator(task_id=self.TASK_ID, dag=dag) dagbag.bag_dag(dag, parent_dag=dag, root_dag=dag) ti = TaskInstance(task=task, execution_date=self.DEFAULT_DATE) ti.try_number = 1 self.session.merge(ti) self.session.commit()
def test_constructor_proxyfix(self): app, _ = application.create_app(session=Session, testing=True) self.assertTrue(isinstance(app.wsgi_app, ProxyFix)) self.assertEqual(app.wsgi_app.x_for, 1) self.assertEqual(app.wsgi_app.x_proto, 1) self.assertEqual(app.wsgi_app.x_host, 1) self.assertEqual(app.wsgi_app.x_port, 1) self.assertEqual(app.wsgi_app.x_prefix, 1)
def test_constructor_proxyfix_args(self): app, _ = application.create_app(testing=True) self.assertTrue(isinstance(app.wsgi_app, ProxyFix)) self.assertEqual(app.wsgi_app.x_for, 3) self.assertEqual(app.wsgi_app.x_proto, 4) self.assertEqual(app.wsgi_app.x_host, 5) self.assertEqual(app.wsgi_app.x_port, 6) self.assertEqual(app.wsgi_app.x_prefix, 7)
def create_app(config=None, testing=False): from airflow.www_rbac import app as airflow_app app, appbuilder = airflow_app.create_app(config=config, testing=testing) # only now we can load view.. use_databand_airflow_dagbag() logging.info("Airflow applications has been created") return app, appbuilder
def setUp(self): self.app, self.appbuilder = application.create_app(session=Session, testing=True) self.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' self.app.config['SECRET_KEY'] = 'secret_key' self.app.config['CSRF_ENABLED'] = False self.app.config['WTF_CSRF_ENABLED'] = False self.client = self.app.test_client() settings.configure_orm() self.session = Session
def setUp(self): conf.load_test_config() self.app, self.appbuilder = application.create_app(session=Session, testing=True) self.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' self.app.config['SECRET_KEY'] = 'secret_key' self.app.config['CSRF_ENABLED'] = False self.app.config['WTF_CSRF_ENABLED'] = False self.client = self.app.test_client() settings.configure_orm() self.session = Session
def create_app(config=None, testing=False): from airflow.www_rbac import app as airflow_app app, appbuilder = airflow_app.create_app(config=config, testing=testing) # only now we can load view.. # this import might causes circular dependency if placed above from dbnd_airflow.airflow_override.dbnd_aiflow_webserver import ( use_databand_airflow_dagbag, ) use_databand_airflow_dagbag() logging.info("Airflow applications has been created") return app, appbuilder
def setUp(self): configuration.load_test_config() try: configuration.conf.add_section("api") except Exception: pass configuration.conf.set("api", "auth_backend", "airflow.api.auth.backend.kerberos_auth") try: configuration.conf.add_section("kerberos") except Exception: pass configuration.conf.set("kerberos", "keytab", os.environ['KRB5_KTNAME']) self.app, _ = application.create_app(testing=True)
def setUp(self): configuration.load_test_config() try: configuration.conf.add_section("api") except Exception: pass configuration.conf.set("api", "auth_backend", "airflow.api.auth.backend.kerberos_auth") try: configuration.conf.add_section("kerberos") except Exception: pass configuration.conf.set("kerberos", "keytab", os.environ['KRB5_KTNAME']) self.app, _ = application.create_app(testing=True)
def setUp(self): super(TestPoolApiExperimental, self).setUp() configuration.load_test_config() app, _ = application.create_app(testing=True) self.app = app.test_client() self.session = Session() self.pools = [] for i in range(2): name = 'experimental_%s' % (i + 1) pool = Pool( pool=name, slots=i, description=name, ) self.session.add(pool) self.pools.append(pool) self.session.commit() self.pool = self.pools[0]
def setUp(self): super(TestPoolApiExperimental, self).setUp() configuration.load_test_config() app, _ = application.create_app(testing=True) self.app = app.test_client() self.session = Session() self.pools = [] for i in range(2): name = 'experimental_%s' % (i + 1) pool = Pool( pool=name, slots=i, description=name, ) self.session.add(pool) self.pools.append(pool) self.session.commit() self.pool = self.pools[0]
def setUp(self): super(TestApiExperimental, self).setUp() configuration.load_test_config() app, _ = application.create_app(testing=True) self.app = app.test_client()
def setUp(self): conf.load_test_config() self.app, self.appbuilder = application.create_app(testing=True)
def setUp(self): super(TestDagRunsEndpoint, self).setUp() app, _ = application.create_app(testing=True) self.app = app.test_client()
def setUp(self): super(TestApiExperimental, self).setUp() configuration.load_test_config() app, _ = application.create_app(testing=True) self.app = app.test_client()
def setUp(self): super(TestDagRunsEndpoint, self).setUp() configuration.load_test_config() app, _ = application.create_app(testing=True) self.app = app.test_client()
def setUp(self): self.app, self.appbuilder = application.create_app(testing=True)
def setUp(self): conf.set("kerberos", "keytab", os.environ['KRB5_KTNAME']) self.app, _ = application.create_app(testing=True)
def setUp(self): conf.load_test_config() self.app, self.appbuilder = application.create_app(testing=True)
def test_constructor_no_proxyfix(self): app, _ = application.create_app(testing=True) self.assertFalse(isinstance(app.wsgi_app, ProxyFix))