diff --git a/adapter/integration_tests/features/steps/fal_adapter_steps.py b/adapter/integration_tests/features/steps/fal_adapter_steps.py index 8883ff5b3..9ef2742e5 100644 --- a/adapter/integration_tests/features/steps/fal_adapter_steps.py +++ b/adapter/integration_tests/features/steps/fal_adapter_steps.py @@ -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}' @@ -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): diff --git a/adapter/integration_tests/projects/simple_project/dbt_project.yml b/adapter/integration_tests/projects/simple_project/dbt_project.yml index 825bedb18..44e7d5e32 100644 --- a/adapter/integration_tests/projects/simple_project/dbt_project.yml +++ b/adapter/integration_tests/projects/simple_project/dbt_project.yml @@ -12,3 +12,8 @@ target-path: "{{ env_var('temp_dir') }}/target" models: +schema: custom + simple_test: + python: + +materialized: table + base: + +materialized: table diff --git a/adapter/integration_tests/projects/simple_project/models/model_a.sql b/adapter/integration_tests/projects/simple_project/models/base/model_a.sql similarity index 85% rename from adapter/integration_tests/projects/simple_project/models/model_a.sql rename to adapter/integration_tests/projects/simple_project/models/base/model_a.sql index 47865e2c3..d2a2753b4 100644 --- a/adapter/integration_tests/projects/simple_project/models/model_a.sql +++ b/adapter/integration_tests/projects/simple_project/models/base/model_a.sql @@ -1,4 +1,3 @@ -{{ config(materialized='table') }} WITH data AS ( SELECT diff --git a/adapter/integration_tests/projects/simple_project/models/model_b.sql b/adapter/integration_tests/projects/simple_project/models/base/model_b.sql similarity index 78% rename from adapter/integration_tests/projects/simple_project/models/model_b.sql rename to adapter/integration_tests/projects/simple_project/models/base/model_b.sql index 4331200a8..c83eca3bf 100644 --- a/adapter/integration_tests/projects/simple_project/models/model_b.sql +++ b/adapter/integration_tests/projects/simple_project/models/base/model_b.sql @@ -1,5 +1,3 @@ -{{ config(materialized='table') }} - WITH data AS ( SELECT cast(1 AS integer) AS my_int, diff --git a/adapter/integration_tests/projects/simple_project/models/model_c.py b/adapter/integration_tests/projects/simple_project/models/python/model_c.py similarity index 78% rename from adapter/integration_tests/projects/simple_project/models/model_c.py rename to adapter/integration_tests/projects/simple_project/models/python/model_c.py index 147a5223e..0f5de7bf7 100644 --- a/adapter/integration_tests/projects/simple_project/models/model_c.py +++ b/adapter/integration_tests/projects/simple_project/models/python/model_c.py @@ -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() diff --git a/adapter/integration_tests/projects/simple_project/models/schema.yml b/adapter/integration_tests/projects/simple_project/models/schema.yml index dc9170542..f3edb61fb 100644 --- a/adapter/integration_tests/projects/simple_project/models/schema.yml +++ b/adapter/integration_tests/projects/simple_project/models/schema.yml @@ -4,4 +4,5 @@ models: - name: model_a - name: model_b - name: model_c # Python model + - name: model_c2 # not existent - name: model_d