Spaces:
Running on Zero
Running on Zero
File size: 978 Bytes
f07ef1d | 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 | from pathlib import Path
from data_engine import DataContext
BASE = Path(__file__).parents[1]
# Check that profiling and data quality checks return expected results
def test_profile_and_quality():
ctx=DataContext.from_path(BASE/"examples"/"dirty_orders.csv")
assert ctx.profile()["rows"] == 8
assert ctx.profile()["columns"] == 5
assert ctx.quality_report()["issue_count"] > 0
# Verify that schema validation detects invalid data
def test_schema_validation_detects_failures():
ctx=DataContext.from_path(BASE/"examples"/"dirty_orders.csv")
result=ctx.validate_schema((BASE/"examples"/"expected_schema.json").read_text())
assert result["valid"] is False
# Verify that read-only SQL queries can be executed successfully
def test_readonly_sql():
ctx=DataContext.from_path(BASE/"examples"/"dirty_orders.csv")
result=ctx.execute_sql("SELECT COUNT(*) AS n FROM dataset")
assert result["ok"] is True
assert result["preview"][0]["n"] == 8
|