def set_tracking_context(): try: reset_dbnd_project_config() get_dbnd_project_config()._dbnd_tracking = True yield finally: reset_dbnd_project_config()
def set_airflow_context(): with patch( "dbnd._core.tracking.airflow_dag_inplace_tracking.try_get_airflow_context" ) as m: try: reset_dbnd_project_config() m.return_value = AirflowTaskContext( dag_id="test_dag", task_id="test_task", execution_date=utcnow().isoformat(), ) yield finally: # ensure dbnd_run_stop() is called (normally should happen on exit() ) dbnd_run_stop() reset_dbnd_project_config()
def databand_clean_project_config_for_every_test(): reset_dbnd_project_config() yield reset_dbnd_project_config()
from __future__ import print_function import os from pytest import fixture from dbnd._core.configuration.environ_config import reset_dbnd_project_config home = os.path.abspath( os.path.normpath(os.path.join(os.path.dirname(__file__), "home")) ) os.environ["DBND_HOME"] = home os.environ["AIRFLOW_HOME"] = home os.environ["AIRFLOW__CORE__UNIT_TEST_MODE"] = "True" reset_dbnd_project_config() @fixture def unittests_db(): return "fetch-unittests.db" @fixture def empty_db(): return "empty-unittests.db" @fixture def incomplete_data_db(): return "incomplete-unittests.db"
def pytest_configure(config): if not os.path.exists(TEST_DBND_HOME): os.mkdir(TEST_DBND_HOME) os.environ["DBND_HOME"] = TEST_DBND_HOME reset_dbnd_project_config()