mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-06-18 15:29:36 +00:00
PROBLEM
The codebase used Python 3.11+ stdlib features (`from datetime import UTC`,
`from enum import StrEnum`) in 22 files, breaking local dev on Python 3.10
(Windows users) and any pytest run that imports the affected modules.
SOLUTION
1. New `core/_py_compat.py` providing UTC + StrEnum shims that:
- On 3.11+ re-export the stdlib names (zero overhead)
- On 3.10 fall back to `timezone.utc` and a (str, Enum) backport
2. All 22 affected files patched to import from the shim:
- core/utils.py, core/config/models.py
- api/routers/admin.py
- auto_client_acquisition/{ai/model_router, agents/{intake,icp_matcher},
v3/{memory,agents,compliance_os,market_radar},
personal_operator/{operator,memory,launch_report},
innovation/{proof_ledger_repo,command_feed_live}}.py
- autonomous_growth/agents/sector_intel.py
- dealix/{trust/{approval,tool_verification,policy},
observability/cost_tracker,
contracts/{evidence_pack,event_envelope,audit_log,decision},
classifications/__init__,
governance/approvals}.py
3. Three new test suites for previously-untested layers (54 tests):
- tests/unit/test_business_suite.py — gtm_plan, launch_metrics,
market_positioning, pricing_strategy, proof_pack, unit_economics,
verticals (28 tests covering plan recommendation, performance fee,
ROI math, account health grading, vertical playbook structure)
- tests/unit/test_innovation_suite.py — aeo_radar, command_feed,
deal_rooms, experiments, growth_missions, proof_ledger, ten_in_ten
(18 tests covering deterministic reproducibility, card type taxonomy,
pending-approval invariant, kill-mission visibility)
- tests/unit/test_ai_model_router.py — ModelTask + get_model_route +
estimate_model_cost_class + requires_guardrail (8 tests covering
enum integrity, route round-trip, guardrail bool contract)
VERIFICATION
- ast.parse green on all 22 patched files
- pytest tests/unit/ → 477 passed, 2 skipped (provider smoke needs API keys)
on Python 3.10.12 venv with project requirements installed
- No behavior change on 3.11+: the shim re-exports stdlib symbols
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
228 lines
7.0 KiB
Python
228 lines
7.0 KiB
Python
"""
|
|
Unit tests for the dealix.business layer — pure functions, no I/O.
|
|
|
|
Covers: gtm_plan / launch_metrics / market_positioning / pricing_strategy /
|
|
proof_pack / unit_economics / verticals.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from auto_client_acquisition.business import (
|
|
gtm_plan,
|
|
launch_metrics,
|
|
market_positioning,
|
|
pricing_strategy,
|
|
proof_pack,
|
|
unit_economics,
|
|
verticals,
|
|
)
|
|
|
|
|
|
# ── gtm_plan ─────────────────────────────────────────────────────
|
|
def test_first_10_plan_has_milestones():
|
|
p = gtm_plan.first_10_customers_plan()
|
|
assert isinstance(p, dict)
|
|
assert p # non-empty
|
|
|
|
|
|
def test_first_100_plan_distinct_from_first_10():
|
|
p10 = gtm_plan.first_10_customers_plan()
|
|
p100 = gtm_plan.first_100_customers_plan()
|
|
# They should not be byte-identical structures
|
|
assert p10 != p100
|
|
|
|
|
|
def test_channel_strategy_returns_dict():
|
|
out = gtm_plan.channel_strategy()
|
|
assert isinstance(out, dict)
|
|
assert out
|
|
|
|
|
|
def test_partner_strategy_returns_dict():
|
|
out = gtm_plan.partner_strategy()
|
|
assert isinstance(out, dict)
|
|
|
|
|
|
def test_founder_led_sales_script_has_content():
|
|
s = gtm_plan.founder_led_sales_script()
|
|
assert isinstance(s, dict)
|
|
assert s
|
|
|
|
|
|
# ── launch_metrics ───────────────────────────────────────────────
|
|
def test_north_star_metrics_dict():
|
|
out = launch_metrics.north_star_metrics()
|
|
assert isinstance(out, dict)
|
|
assert out
|
|
|
|
|
|
def test_activation_metrics_dict():
|
|
assert isinstance(launch_metrics.activation_metrics(), dict)
|
|
|
|
|
|
def test_retention_metrics_dict():
|
|
assert isinstance(launch_metrics.retention_metrics(), dict)
|
|
|
|
|
|
def test_revenue_metrics_dict():
|
|
assert isinstance(launch_metrics.revenue_metrics(), dict)
|
|
|
|
|
|
def test_ai_quality_metrics_dict():
|
|
assert isinstance(launch_metrics.ai_quality_metrics(), dict)
|
|
|
|
|
|
# ── market_positioning ───────────────────────────────────────────
|
|
def test_compare_competitors_returns_list():
|
|
out = market_positioning.compare_competitors()
|
|
assert isinstance(out, list)
|
|
assert len(out) > 0
|
|
|
|
|
|
def test_dealix_differentiators_non_empty_strings():
|
|
out = market_positioning.dealix_differentiators()
|
|
assert isinstance(out, list)
|
|
assert len(out) > 0
|
|
assert all(isinstance(x, str) and x for x in out)
|
|
|
|
|
|
def test_positioning_statement_returns_string():
|
|
# Try a known segment value
|
|
statement = market_positioning.positioning_statement("smb")
|
|
assert isinstance(statement, str)
|
|
assert len(statement) > 0
|
|
|
|
|
|
# ── pricing_strategy ─────────────────────────────────────────────
|
|
def test_get_pricing_tiers_structure():
|
|
out = pricing_strategy.get_pricing_tiers()
|
|
assert isinstance(out, dict)
|
|
assert out["currency"] == "SAR"
|
|
assert isinstance(out["tiers"], list)
|
|
keys = {t["key"] for t in out["tiers"]}
|
|
# Required tiers per pricing strategy doc
|
|
for required in ("founder_operator", "growth_os", "scale_os"):
|
|
assert required in keys, f"missing tier: {required}"
|
|
|
|
|
|
def test_recommend_plan_returns_known_key():
|
|
out = pricing_strategy.recommend_plan(
|
|
company_size="smb",
|
|
monthly_budget_sar=3000,
|
|
goal="grow_pipeline",
|
|
)
|
|
assert isinstance(out, dict)
|
|
# Real shape: {recommended_plan, rationale_ar, tier_summary, inputs}
|
|
assert "recommended_plan" in out
|
|
assert "rationale_ar" in out
|
|
assert "tier_summary" in out
|
|
|
|
|
|
def test_calculate_performance_fee_non_negative():
|
|
out = pricing_strategy.calculate_performance_fee(
|
|
qualified_leads=20,
|
|
booked_meetings=8,
|
|
won_revenue_sar=120_000,
|
|
)
|
|
assert isinstance(out, dict)
|
|
for k, v in out.items():
|
|
if isinstance(v, (int, float)):
|
|
assert v >= 0, f"{k} should be non-negative, got {v}"
|
|
|
|
|
|
def test_estimate_roi_returns_dict():
|
|
out = pricing_strategy.estimate_roi(
|
|
plan_price_sar=2999,
|
|
expected_pipeline_sar=120_000,
|
|
expected_revenue_sar=30_000,
|
|
)
|
|
assert isinstance(out, dict)
|
|
assert out
|
|
|
|
|
|
# ── proof_pack ───────────────────────────────────────────────────
|
|
def test_demo_proof_pack_structure():
|
|
out = proof_pack.build_demo_proof_pack()
|
|
assert isinstance(out, dict)
|
|
assert out
|
|
|
|
|
|
def test_calculate_roi_summary_handles_zero_subscription():
|
|
"""Should not divide-by-zero on zero subscription."""
|
|
out = proof_pack.calculate_roi_summary(
|
|
subscription_sar=0,
|
|
influenced_revenue_sar=0,
|
|
hours_saved=0,
|
|
)
|
|
assert isinstance(out, dict)
|
|
|
|
|
|
def test_calculate_roi_summary_normal():
|
|
out = proof_pack.calculate_roi_summary(
|
|
subscription_sar=2999,
|
|
influenced_revenue_sar=200_000,
|
|
hours_saved=40,
|
|
)
|
|
assert isinstance(out, dict)
|
|
# multiple should be positive given non-zero inputs
|
|
assert out
|
|
|
|
|
|
def test_grade_account_health_thresholds():
|
|
healthy = proof_pack.grade_account_health(
|
|
brief_opens_4w=20, approvals_4w=10, blocks_4w=2,
|
|
)
|
|
weak = proof_pack.grade_account_health(
|
|
brief_opens_4w=2, approvals_4w=0, blocks_4w=0,
|
|
)
|
|
# healthy should grade higher
|
|
assert healthy["health_score"] >= weak["health_score"]
|
|
# And the status labels should differ for these extremes
|
|
assert healthy["status"] == "healthy"
|
|
assert weak["status"] == "at_risk"
|
|
|
|
|
|
# ── unit_economics ───────────────────────────────────────────────
|
|
def test_estimate_gross_margin_returns_dict():
|
|
assert isinstance(unit_economics.estimate_gross_margin(), dict)
|
|
|
|
|
|
def test_cac_payback_dict():
|
|
assert isinstance(unit_economics.estimate_cac_payback(), dict)
|
|
|
|
|
|
def test_estimate_ltv_dict():
|
|
assert isinstance(unit_economics.estimate_ltv(), dict)
|
|
|
|
|
|
def test_estimate_mrr_path_dict():
|
|
out = unit_economics.estimate_mrr_path()
|
|
assert isinstance(out, dict)
|
|
|
|
|
|
# ── verticals ────────────────────────────────────────────────────
|
|
def test_get_vertical_playbooks():
|
|
out = verticals.get_vertical_playbooks()
|
|
assert isinstance(out, dict)
|
|
# Verticals are nested under 'verticals' key
|
|
inner = out.get("verticals", {})
|
|
assert "clinics" in inner or "real_estate" in inner or "logistics" in inner
|
|
|
|
|
|
def test_recommend_vertical_returns_dict():
|
|
out = verticals.recommend_vertical(
|
|
industry="medical",
|
|
city="Riyadh",
|
|
goal="bookings",
|
|
)
|
|
assert isinstance(out, dict)
|
|
|
|
|
|
def test_vertical_roi_metric_returns_string():
|
|
# Try a known vertical
|
|
out = verticals.vertical_roi_metric("clinics")
|
|
assert isinstance(out, str)
|
|
assert out
|