Spaces:
Running
Running
Saibalaji Namburi commited on
Commit ·
8634e4f
1
Parent(s): 7317d6e
ci: fix missing rank-bm25 package and generate mock duckdb in conftest
Browse files- requirements-ci.txt +1 -0
- tests/conftest.py +127 -0
requirements-ci.txt
CHANGED
|
@@ -104,6 +104,7 @@ tqdm==4.67.3
|
|
| 104 |
bcrypt==5.0.0
|
| 105 |
pyjwt==2.12.1
|
| 106 |
oauthlib==3.3.1
|
|
|
|
| 107 |
|
| 108 |
# --- DBT (for test_dbt_models) ---
|
| 109 |
dbt-core==1.11.10
|
|
|
|
| 104 |
bcrypt==5.0.0
|
| 105 |
pyjwt==2.12.1
|
| 106 |
oauthlib==3.3.1
|
| 107 |
+
rank-bm25==0.2.2
|
| 108 |
|
| 109 |
# --- DBT (for test_dbt_models) ---
|
| 110 |
dbt-core==1.11.10
|
tests/conftest.py
CHANGED
|
@@ -1,5 +1,132 @@
|
|
| 1 |
import pytest
|
| 2 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
@pytest.fixture(autouse=True)
|
| 5 |
def set_test_env_vars():
|
|
|
|
| 1 |
import pytest
|
| 2 |
import os
|
| 3 |
+
import duckdb
|
| 4 |
+
|
| 5 |
+
def init_mock_duckdb():
|
| 6 |
+
db_path = "src/dbt/customercore.duckdb"
|
| 7 |
+
if os.path.exists(db_path):
|
| 8 |
+
return
|
| 9 |
+
|
| 10 |
+
os.makedirs(os.path.dirname(db_path), exist_ok=True)
|
| 11 |
+
conn = duckdb.connect(db_path)
|
| 12 |
+
|
| 13 |
+
conn.execute("CREATE SCHEMA IF NOT EXISTS gold_gold")
|
| 14 |
+
|
| 15 |
+
# customer_health_daily
|
| 16 |
+
conn.execute("""
|
| 17 |
+
CREATE TABLE gold_gold.customer_health_daily (
|
| 18 |
+
customer_id VARCHAR,
|
| 19 |
+
tenant_id VARCHAR,
|
| 20 |
+
snapshot_date TIMESTAMP,
|
| 21 |
+
open_tickets INTEGER,
|
| 22 |
+
avg_priority DOUBLE,
|
| 23 |
+
payment_failures_30d INTEGER
|
| 24 |
+
)
|
| 25 |
+
""")
|
| 26 |
+
conn.execute("""
|
| 27 |
+
INSERT INTO gold_gold.customer_health_daily VALUES
|
| 28 |
+
('c1', 'tenant1', '2026-05-27 12:00:00', 1, 2.5, 0)
|
| 29 |
+
""")
|
| 30 |
+
|
| 31 |
+
# ticket_funnel_daily
|
| 32 |
+
conn.execute("""
|
| 33 |
+
CREATE TABLE gold_gold.ticket_funnel_daily (
|
| 34 |
+
tenant_id VARCHAR,
|
| 35 |
+
event_type VARCHAR,
|
| 36 |
+
priority VARCHAR,
|
| 37 |
+
source VARCHAR,
|
| 38 |
+
event_date TIMESTAMP,
|
| 39 |
+
event_count INTEGER,
|
| 40 |
+
unique_customers INTEGER
|
| 41 |
+
)
|
| 42 |
+
""")
|
| 43 |
+
conn.execute("""
|
| 44 |
+
INSERT INTO gold_gold.ticket_funnel_daily VALUES
|
| 45 |
+
('tenant1', 'type1', 'high', 'email', '2026-05-27 12:00:00', 5, 2)
|
| 46 |
+
""")
|
| 47 |
+
|
| 48 |
+
# incident_severity_hourly
|
| 49 |
+
conn.execute("""
|
| 50 |
+
CREATE TABLE gold_gold.incident_severity_hourly (
|
| 51 |
+
tenant_id VARCHAR,
|
| 52 |
+
incident_hour INTEGER,
|
| 53 |
+
severity VARCHAR,
|
| 54 |
+
incident_count INTEGER,
|
| 55 |
+
affected_customers INTEGER
|
| 56 |
+
)
|
| 57 |
+
""")
|
| 58 |
+
conn.execute("""
|
| 59 |
+
INSERT INTO gold_gold.incident_severity_hourly VALUES
|
| 60 |
+
('tenant1', 14, 'critical', 1, 100)
|
| 61 |
+
""")
|
| 62 |
+
|
| 63 |
+
# billing_failure_summary
|
| 64 |
+
conn.execute("""
|
| 65 |
+
CREATE TABLE gold_gold.billing_failure_summary (
|
| 66 |
+
tenant_id VARCHAR,
|
| 67 |
+
event_date TIMESTAMP,
|
| 68 |
+
priority VARCHAR,
|
| 69 |
+
billing_event_count INTEGER,
|
| 70 |
+
payment_failures INTEGER,
|
| 71 |
+
cancellations INTEGER
|
| 72 |
+
)
|
| 73 |
+
""")
|
| 74 |
+
conn.execute("""
|
| 75 |
+
INSERT INTO gold_gold.billing_failure_summary VALUES
|
| 76 |
+
('tenant1', '2026-05-27 12:00:00', 'high', 3, 2, 1)
|
| 77 |
+
""")
|
| 78 |
+
|
| 79 |
+
# product_adoption_features
|
| 80 |
+
conn.execute("""
|
| 81 |
+
CREATE TABLE gold_gold.product_adoption_features (
|
| 82 |
+
tenant_id VARCHAR,
|
| 83 |
+
customer_id VARCHAR,
|
| 84 |
+
event_date TIMESTAMP,
|
| 85 |
+
total_product_events INTEGER,
|
| 86 |
+
active_days INTEGER
|
| 87 |
+
)
|
| 88 |
+
""")
|
| 89 |
+
conn.execute("""
|
| 90 |
+
INSERT INTO gold_gold.product_adoption_features VALUES
|
| 91 |
+
('tenant1', 'c1', '2026-05-27 12:00:00', 15, 3)
|
| 92 |
+
""")
|
| 93 |
+
|
| 94 |
+
# retention_cohort_metrics
|
| 95 |
+
conn.execute("""
|
| 96 |
+
CREATE TABLE gold_gold.retention_cohort_metrics (
|
| 97 |
+
cohort_date TIMESTAMP,
|
| 98 |
+
tenant_id VARCHAR,
|
| 99 |
+
cohort_size INTEGER,
|
| 100 |
+
retained_d7 INTEGER,
|
| 101 |
+
retained_d30 INTEGER
|
| 102 |
+
)
|
| 103 |
+
""")
|
| 104 |
+
conn.execute("""
|
| 105 |
+
INSERT INTO gold_gold.retention_cohort_metrics VALUES
|
| 106 |
+
('2026-05-27 12:00:00', 'tenant1', 50, 40, 25)
|
| 107 |
+
""")
|
| 108 |
+
|
| 109 |
+
# support_agent_performance
|
| 110 |
+
conn.execute("""
|
| 111 |
+
CREATE TABLE gold_gold.support_agent_performance (
|
| 112 |
+
tenant_id VARCHAR,
|
| 113 |
+
source VARCHAR,
|
| 114 |
+
report_date TIMESTAMP,
|
| 115 |
+
priority VARCHAR,
|
| 116 |
+
tickets_created INTEGER,
|
| 117 |
+
unique_customers_served INTEGER,
|
| 118 |
+
avg_body_length DOUBLE
|
| 119 |
+
)
|
| 120 |
+
""")
|
| 121 |
+
conn.execute("""
|
| 122 |
+
INSERT INTO gold_gold.support_agent_performance VALUES
|
| 123 |
+
('tenant1', 'email', '2026-05-27 12:00:00', 'high', 10, 8, 120.5)
|
| 124 |
+
""")
|
| 125 |
+
|
| 126 |
+
conn.close()
|
| 127 |
+
|
| 128 |
+
# Run initialization before tests run
|
| 129 |
+
init_mock_duckdb()
|
| 130 |
|
| 131 |
@pytest.fixture(autouse=True)
|
| 132 |
def set_test_env_vars():
|