Spaces:
Sleeping
Sleeping
File size: 1,095 Bytes
343ad62 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
from nl2sql.pipeline_factory import (
pipeline_from_config,
pipeline_from_config_with_adapter,
)
from adapters.db.sqlite_adapter import SQLiteAdapter
def test_pipeline_from_config_builds_and_runs(tmp_path):
p = pipeline_from_config("configs/sqlite_pipeline.yaml")
result = p.run(user_query="Top 3 albums by sales")
assert result.sql is not None
assert isinstance(result.traces, list)
def test_pipeline_from_config_with_adapter_override(tmp_path):
adapter = SQLiteAdapter("data/chinook.db")
p = pipeline_from_config_with_adapter(
"configs/sqlite_pipeline.yaml", adapter=adapter
)
result = p.run(user_query="Count customers")
assert "SELECT" in result.sql.upper()
assert isinstance(result.traces, list)
def test_full_pipeline_from_yaml(monkeypatch):
from nl2sql.pipeline_factory import pipeline_from_config
p = pipeline_from_config("configs/sqlite_pipeline.yaml")
res = p.run(user_query="List all artists")
assert res.ok
assert isinstance(res.sql, str)
assert any(t["stage"] == "executor" for t in res.traces)
|