@@ -1025,6 +1025,16 @@ def test_codegen_online_false(self, parser):
10251025class TestDbtCli :
10261026 """Test the `feast dbt import` and `feast dbt list` CLI commands."""
10271027
1028+ @staticmethod
1029+ def _get_cli_output (result ) -> str :
1030+ """Return combined stdout/stderr across Click versions."""
1031+ stderr = getattr (result , "stderr" , "" )
1032+ if not stderr :
1033+ stderr_bytes = getattr (result , "stderr_bytes" , b"" )
1034+ if stderr_bytes :
1035+ stderr = stderr_bytes .decode ("utf-8" , errors = "replace" )
1036+ return result .output + stderr
1037+
10281038 def test_dbt_list_command (self , manifest_path ):
10291039 from click .testing import CliRunner
10301040
@@ -1061,6 +1071,27 @@ def test_dbt_list_show_columns(self, manifest_path):
10611071 assert "driver_id" in result .output
10621072 assert "conv_rate" in result .output
10631073
1074+ def test_dbt_list_import_error (self , manifest_path , monkeypatch ):
1075+ from click .testing import CliRunner
1076+
1077+ from feast .cli .dbt_import import list_command
1078+ from feast .dbt .parser import DbtManifestParser
1079+
1080+ def _raise_import_error (self ): # pragma: no cover - behavior tested via CLI
1081+ raise ImportError (
1082+ "dbt-artifacts-parser is required for dbt integration.\n "
1083+ "Install with: pip install 'feast[dbt]' or pip install dbt-artifacts-parser"
1084+ )
1085+
1086+ monkeypatch .setattr (DbtManifestParser , "parse" , _raise_import_error )
1087+
1088+ runner = CliRunner ()
1089+ result = runner .invoke (list_command , ["-m" , manifest_path ])
1090+ output = self ._get_cli_output (result )
1091+ assert result .exit_code == 1
1092+ assert "dbt-artifacts-parser is required for dbt integration" in output
1093+ assert "feast[dbt]" in output
1094+
10641095 def test_dbt_import_dry_run (self , manifest_path ):
10651096 from click .testing import CliRunner
10661097
@@ -1086,6 +1117,38 @@ def test_dbt_import_dry_run(self, manifest_path):
10861117 assert result .exit_code == 0
10871118 assert "Dry run" in result .output
10881119
1120+ def test_dbt_import_import_error (self , manifest_path , monkeypatch ):
1121+ from click .testing import CliRunner
1122+
1123+ from feast .cli .dbt_import import import_command
1124+ from feast .dbt .parser import DbtManifestParser
1125+
1126+ def _raise_import_error (self ): # pragma: no cover - behavior tested via CLI
1127+ raise ImportError (
1128+ "dbt-artifacts-parser is required for dbt integration.\n "
1129+ "Install with: pip install 'feast[dbt]' or pip install dbt-artifacts-parser"
1130+ )
1131+
1132+ monkeypatch .setattr (DbtManifestParser , "parse" , _raise_import_error )
1133+
1134+ runner = CliRunner ()
1135+ result = runner .invoke (
1136+ import_command ,
1137+ [
1138+ "-m" ,
1139+ manifest_path ,
1140+ "-e" ,
1141+ "driver_id" ,
1142+ "--dry-run" ,
1143+ ],
1144+ obj = {"CHDIR" : "." , "FS_YAML_FILE" : "feature_store.yaml" },
1145+ catch_exceptions = False ,
1146+ )
1147+ output = self ._get_cli_output (result )
1148+ assert result .exit_code == 1
1149+ assert "dbt-artifacts-parser is required for dbt integration" in output
1150+ assert "feast[dbt]" in output
1151+
10891152 def test_dbt_import_output_codegen (self , manifest_path , tmp_path ):
10901153 from click .testing import CliRunner
10911154
0 commit comments