◐ Shell
clean mode source ↗

fix: Catch missing dbt parser dependency in dbt CLI commands by kchawlani19 · Pull Request #6534 · feast-dev/feast

Expand Up @@ -1025,6 +1025,16 @@ def test_codegen_online_false(self, parser): class TestDbtCli: """Test the `feast dbt import` and `feast dbt list` CLI commands."""
@staticmethod def _get_cli_output(result) -> str: """Return combined stdout/stderr across Click versions.""" stderr = getattr(result, "stderr", "") if not stderr: stderr_bytes = getattr(result, "stderr_bytes", b"") if stderr_bytes: stderr = stderr_bytes.decode("utf-8", errors="replace") return result.output + stderr
def test_dbt_list_command(self, manifest_path): from click.testing import CliRunner
Expand Down Expand Up @@ -1061,6 +1071,27 @@ def test_dbt_list_show_columns(self, manifest_path): assert "driver_id" in result.output assert "conv_rate" in result.output
def test_dbt_list_import_error(self, manifest_path, monkeypatch): from click.testing import CliRunner
from feast.cli.dbt_import import list_command from feast.dbt.parser import DbtManifestParser
def _raise_import_error(self): # pragma: no cover - behavior tested via CLI raise ImportError( "dbt-artifacts-parser is required for dbt integration.\n" "Install with: pip install 'feast[dbt]' or pip install dbt-artifacts-parser" )
monkeypatch.setattr(DbtManifestParser, "parse", _raise_import_error)
runner = CliRunner() result = runner.invoke(list_command, ["-m", manifest_path]) output = self._get_cli_output(result) assert result.exit_code == 1 assert "dbt-artifacts-parser is required for dbt integration" in output assert "feast[dbt]" in output
def test_dbt_import_dry_run(self, manifest_path): from click.testing import CliRunner
Expand All @@ -1086,6 +1117,38 @@ def test_dbt_import_dry_run(self, manifest_path): assert result.exit_code == 0 assert "Dry run" in result.output
def test_dbt_import_import_error(self, manifest_path, monkeypatch): from click.testing import CliRunner
from feast.cli.dbt_import import import_command from feast.dbt.parser import DbtManifestParser
def _raise_import_error(self): # pragma: no cover - behavior tested via CLI raise ImportError( "dbt-artifacts-parser is required for dbt integration.\n" "Install with: pip install 'feast[dbt]' or pip install dbt-artifacts-parser" )
monkeypatch.setattr(DbtManifestParser, "parse", _raise_import_error)
runner = CliRunner() result = runner.invoke( import_command, [ "-m", manifest_path, "-e", "driver_id", "--dry-run", ], obj={"CHDIR": ".", "FS_YAML_FILE": "feature_store.yaml"}, catch_exceptions=False, ) output = self._get_cli_output(result) assert result.exit_code == 1 assert "dbt-artifacts-parser is required for dbt integration" in output assert "feast[dbt]" in output
def test_dbt_import_output_codegen(self, manifest_path, tmp_path): from click.testing import CliRunner
Expand Down