|
39 | 39 | local_dependency__models__model_to_import_sql, |
40 | 40 | local_dependency__models__schema_yml, |
41 | 41 | local_dependency__seeds__seed_csv, |
| 42 | + macros_schema1_yml, |
| 43 | + macros_schema2_yml, |
42 | 44 | macros_schema_yml, |
| 45 | + macros_sql, |
43 | 46 | macros_yml, |
44 | 47 | model_a_sql, |
45 | 48 | model_b_sql, |
@@ -255,13 +258,24 @@ def test_pp_models(self, project): |
255 | 258 | with pytest.raises(CompilationError): |
256 | 259 | results = run_dbt(["--partial-parse", "--warn-error", "run"]) |
257 | 260 |
|
258 | | - # put back macro file, got back to schema file with no macro |
| 261 | + # put back macro file, go back to schema file with no macro |
259 | 262 | # add separate macro patch schema file |
260 | 263 | write_file(models_schema2_yml, project.project_root, "models", "schema.yml") |
261 | 264 | write_file(my_macro_sql, project.project_root, "macros", "my_macro.sql") |
262 | 265 | write_file(macros_yml, project.project_root, "macros", "macros.yml") |
263 | 266 | results = run_dbt(["--partial-parse", "run"]) |
264 | 267 |
|
| 268 | + # add macro file with two macros and schema file with patches for both |
| 269 | + write_file(macros_schema1_yml, project.project_root, "macros", "macros_x.yml") |
| 270 | + write_file(macros_sql, project.project_root, "macros", "macros_x.sql") |
| 271 | + results = run_dbt(["--partial-parse", "parse"]) |
| 272 | + |
| 273 | + # modify one of the patches |
| 274 | + write_file(macros_schema2_yml, project.project_root, "macros", "macros_x.yml") |
| 275 | + results = run_dbt(["--partial-parse", "parse"]) |
| 276 | + rm_file(project.project_root, "macros", "macros_x.sql") |
| 277 | + rm_file(project.project_root, "macros", "macros_x.yml") |
| 278 | + |
265 | 279 | # delete macro and schema file |
266 | 280 | rm_file(project.project_root, "macros", "my_macro.sql") |
267 | 281 | rm_file(project.project_root, "macros", "macros.yml") |
@@ -565,6 +579,58 @@ def test_skip_macros(self, project): |
565 | 579 | assert "Starting full parse." in log_output |
566 | 580 |
|
567 | 581 |
|
| 582 | +class TestMacroDescriptionUpdate: |
| 583 | + @pytest.fixture(scope="class") |
| 584 | + def models(self): |
| 585 | + return { |
| 586 | + "my_model.sql": model_one_sql, |
| 587 | + } |
| 588 | + |
| 589 | + @pytest.fixture(scope="class") |
| 590 | + def macros(self): |
| 591 | + return { |
| 592 | + "macros.sql": macros_sql, |
| 593 | + "schema.yml": macros_schema1_yml, |
| 594 | + } |
| 595 | + |
| 596 | + def test_pp_macro_description_update(self, project): |
| 597 | + # initial parse |
| 598 | + run_dbt(["parse"]) |
| 599 | + |
| 600 | + manifest = get_manifest(project.project_root) |
| 601 | + assert "macro.test.foo" in manifest.macros |
| 602 | + assert "macro.test.bar" in manifest.macros |
| 603 | + assert manifest.macros["macro.test.foo"].description == "Lorem." |
| 604 | + assert manifest.macros["macro.test.bar"].description == "Lorem." |
| 605 | + assert manifest.macros["macro.test.foo"].patch_path == "test://" + normalize( |
| 606 | + "macros/schema.yml" |
| 607 | + ) |
| 608 | + assert manifest.macros["macro.test.bar"].patch_path == "test://" + normalize( |
| 609 | + "macros/schema.yml" |
| 610 | + ) |
| 611 | + |
| 612 | + # edit YAML in macros-path |
| 613 | + write_file(macros_schema2_yml, project.project_root, "macros", "schema.yml") |
| 614 | + |
| 615 | + # parse again |
| 616 | + run_dbt(["--partial-parse", "parse"]) |
| 617 | + |
| 618 | + manifest = get_manifest(project.project_root) |
| 619 | + assert "macro.test.foo" in manifest.macros |
| 620 | + assert "macro.test.bar" in manifest.macros |
| 621 | + assert manifest.macros["macro.test.foo"].description == "Lorem." |
| 622 | + assert manifest.macros["macro.test.bar"].description == "Lorem ipsum." |
| 623 | + assert manifest.macros["macro.test.foo"].patch_path == "test://" + normalize( |
| 624 | + "macros/schema.yml" |
| 625 | + ) |
| 626 | + assert manifest.macros["macro.test.bar"].patch_path == "test://" + normalize( |
| 627 | + "macros/schema.yml" |
| 628 | + ) |
| 629 | + |
| 630 | + # compile |
| 631 | + run_dbt(["--partial-parse", "compile"]) |
| 632 | + |
| 633 | + |
568 | 634 | class TestSnapshots: |
569 | 635 | @pytest.fixture(scope="class") |
570 | 636 | def models(self): |
|
0 commit comments