From 14e0152576cedb8dbf974dc925961b29447c585b Mon Sep 17 00:00:00 2001 From: Ian Knox <81931810+iknox-fa@users.noreply.github.com> Date: Tue, 16 May 2023 13:50:28 -0500 Subject: [PATCH] Missed PR fedback (#7642) (cherry picked from commit df23f68dd4e26a5fa19e5cbed4b9f2cf33e62a7d) --- .../dependencies/test_local_dependency.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/functional/dependencies/test_local_dependency.py b/tests/functional/dependencies/test_local_dependency.py index 559a1b25586..6b413779e94 100644 --- a/tests/functional/dependencies/test_local_dependency.py +++ b/tests/functional/dependencies/test_local_dependency.py @@ -8,6 +8,7 @@ from pathlib import Path from unittest import mock +from contextlib import contextmanager import dbt.semver import dbt.config @@ -16,6 +17,7 @@ from dbt.tests.util import ( check_relations_equal, run_dbt, + run_dbt_and_capture, ) models__dep_source = """ @@ -85,6 +87,16 @@ """ +@contextmanager +def up_one(): + current_path = Path.cwd() + os.chdir("../") + try: + yield + finally: + os.chdir(current_path) + + class BaseDependencyTest(object): @pytest.fixture(scope="class") def macros(self): @@ -174,6 +186,16 @@ def test_no_dependency_paths(self, project): assert len(results) == 2 +class TestSimpleDependencyRelativePath(BaseDependencyTest): + def test_local_dependency_relative_path(self, project): + last_dir = Path(project.project_root).name + with up_one(): + _, stdout = run_dbt_and_capture(["deps", "--project-dir", last_dir]) + assert ( + "Installed from " in stdout + ), "Test output didn't contain expected string" + + class TestMissingDependency(object): @pytest.fixture(scope="class") def models(self):