from catopt_query.adapters import PostgresAdapter, PostgresVendorPlan, MongoAdapter, MongoVendorPlan from catopt_query.protocol import CanonicalPlan def test_postgres_adapter_roundtrip(): vendor = PostgresVendorPlan( shard_id="s1", table="t1", projection=["a", "b"], predicates=["a>0"], price=10.0, ) adapter = PostgresAdapter() canon = adapter.to_canonical(vendor) assert isinstance(canon, CanonicalPlan) assert canon.projection == ["a", "b"] assert canon.predicates == ["a>0"] assert canon.estimated_cost == 10.0 def test_mongo_adapter_roundtrip(): vendor = MongoVendorPlan( shard_id="s2", collection="coll", projection=["x"], predicates=["x<5"], price=5.5, ) adapter = MongoAdapter() canon = adapter.to_canonical(vendor) assert isinstance(canon, CanonicalPlan) assert canon.projection == ["x"] assert canon.predicates == ["x<5"] assert canon.estimated_cost == 5.5