Skip to content

Commit

Permalink
add DEFAULT_ENV_VARS and test_path arg
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-rogers-dbt committed Jan 8, 2024
1 parent 6361429 commit 6bca5dc
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions dagger/run_dbt_spark_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
PG_PORT = 5432
load_dotenv(find_dotenv("test.env"))
DEFAULT_ENV_VARS = {
"DBT_TEST_USER_1": "[email protected]",
"DBT_TEST_USER_2":"[email protected]",
"DBT_TEST_USER_3": "[email protected]",
"DBT_TEST_USER_1": os.getenv("DBT_TEST_USER_1", "[email protected]"),
"DBT_TEST_USER_2": os.getenv("DBT_TEST_USER_2","[email protected]"),
"DBT_TEST_USER_3": os.getenv("DBT_TEST_USER_3", "[email protected]"),
}


def env_variables(envs: dict[str, str]):
def env_variables_inner(ctr: dagger.Container):
for key, value in envs.items():
Expand All @@ -25,7 +26,6 @@ def env_variables_inner(ctr: dagger.Container):


def get_databricks_env_vars():

return {
"DBT_DATABRICKS_TOKEN": os.environ["DBT_DATABRICKS_TOKEN"],
"DBT_DATABRICKS_HOST_NAME": os.environ["DBT_DATABRICKS_HOST_NAME"],
Expand Down Expand Up @@ -123,25 +123,22 @@ async def test_spark(test_args):
if "databricks" in test_profile:
tst_container = tst_container.with_(env_variables(get_databricks_env_vars()))
tst_container = tst_container.with_(env_variables(DEFAULT_ENV_VARS))
test_path = test_args.test_path if test_args.test_path else "tests/functional/adapter"
result = await tst_container.with_exec(
[
"python",
"-m",
"pytest",
"-v",
"--profile",
test_args.profile,
"-n",
"auto",
"tests/functional/",
]
["python", "-m", "pytest",
"-v",
"--profile", test_args.profile,
"-n", "auto",
test_path,
]
).stdout()

return result


parser = argparse.ArgumentParser()
parser.add_argument("--profile", required=True, type=str)
parser.add_argument("--test-path", required=False, type=str)
args = parser.parse_args()

anyio.run(test_spark, args)

0 comments on commit 6bca5dc

Please sign in to comment.