Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
tests(dbt-fal): add resource-paths to dbt_project.yml to make sure it…
Browse files Browse the repository at this point in the history
… is picked up by dbt (#714)

* tests: add resource-paths to dbt_project.yml to make sure it is being picked up

* find models in any depth of model dir
  • Loading branch information
chamini2 authored Jan 12, 2023
1 parent aec3483 commit e6ccfaa
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
26 changes: 13 additions & 13 deletions adapter/integration_tests/features/steps/fal_adapter_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def check_compiled_model(context, model_type: str, model_name: str, msg: str):
assert model_type in ["sql", "python", "py"], "model type should be SQL or Python"
if model_type == "python":
model_type = "py"
compiled = _load_target_run_model(context, f"{model_name}.{model_type}")
compiled = _load_target_run_model(context, model_name, model_type)
assert msg in compiled, f'Expected "{msg}" not present in compiled model {compiled}'


Expand Down Expand Up @@ -104,18 +104,18 @@ def _load_dbt_project_file(context):
return yaml.full_load(stream)


def _load_target_run_model(context, model_with_ext: str):
with open(
os.path.join(
context.temp_dir.name,
"target",
"run",
context.project_name,
"models",
model_with_ext,
)
) as stream:
return stream.read()
def _load_target_run_model(context, model_name: str, file_ext: str):

# TODO: we should use fal to find these files from fal reading the dbt_project.yml and making it easily available
models_dir: Path = (
Path(context.temp_dir.name) / "target" / "run" / context.project_name / "models"
)

found_model_files = list(models_dir.rglob(f"{model_name}.{file_ext}"))

assert len(found_model_files) == 1, "Model must be unique in models directory"

return found_model_files[0].read_text()


def _replace_vars(context, msg):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ target-path: "{{ env_var('temp_dir') }}/target"

models:
+schema: custom
simple_test:
python:
+materialized: table
base:
+materialized: table
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{ config(materialized='table') }}
WITH data AS (

SELECT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{{ config(materialized='table') }}

WITH data AS (
SELECT
cast(1 AS integer) AS my_int,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
def model(dbt, fal):
from utils.get_bool import get_bool

dbt.config(materialized="table")
df = dbt.ref("model_b")

df["my_bool"] = get_bool()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ models:
- name: model_a
- name: model_b
- name: model_c # Python model
- name: model_c2 # not existent
- name: model_d

0 comments on commit e6ccfaa

Please sign in to comment.