Skip to main content
Glama
test_dbt_compile.py1.84 kB
#!/usr/bin/env python3 """ Integration test for the dbt_compile tool that compiles dbt models. """ import os import sys import json from pathlib import Path # Add parent directory to python path to import from common.py sys.path.append(str(Path(__file__).parent)) from common import run_cli_command, verify_output, verify_files_exist, cleanup_target_dir # Path to the jaffle_shop project JAFFLE_SHOP_PATH = Path(__file__).parent.parent / "dbt_integration_tests/jaffle_shop_duckdb" def test_dbt_compile(): """Test the dbt_compile tool by compiling a specific model""" print("Testing dbt_compile tool...") # Clean up target directory first cleanup_target_dir(JAFFLE_SHOP_PATH) try: # Call the dbt_compile tool to compile the customers model print("Running dbt_compile for customers model...") compile_result = run_cli_command("compile", { "project_dir": str(JAFFLE_SHOP_PATH), "models": "customers" }) # Print the compile result for debugging print(f"Compile result: {compile_result[:200]}...") # Don't check for specific text, just proceed print("✅ Model compilation completed") # Verify the target files were created target_files = [ JAFFLE_SHOP_PATH / "target" / "compiled" / "jaffle_shop" / "models" / "customers.sql" ] files_exist = verify_files_exist(target_files) assert files_exist, "Verification failed" print("✅ Test passed!") except Exception as e: print(f"❌ Test failed with exception: {e}") import traceback traceback.print_exc() raise if __name__ == "__main__": try: test_dbt_compile() sys.exit(0) except Exception: sys.exit(1)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MammothGrowth/dbt-cli-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server