system-prompts-and-models-o.../dealix/tests/unit/test_launch_ops.py
Dealix Builder 84f1ad9620 feat(launch+revenue): Private Beta Launch Ops + Revenue Launch — 14 modules + 29 endpoints + 56 tests + scripts/landing/docs
Launch Ops (5 modules) — برج إطلاق الـ Private Beta
- private_beta: 499 SAR × 7-day offer + safety notes + 6-question Arabic FAQ
- demo_flow: 12-minute minute-by-minute Arabic demo + 5 discovery Qs + 6 objection responses + close script
- outreach_messages: 4 segments × 5 prospects = 20 + per-segment Arabic messages + 3-step follow-ups + 6 reply handlers
- go_no_go: 10-gate readiness + 3 critical gates (no_secrets/live_sends_disabled/staging_health) + verdict + next-actions
- launch_scorecard: 11 event types + daily/weekly aggregation + targets (20 outreach/5 replies/3 demos/1 pilot daily)

Revenue Launch (7 modules) — تحويل Dealix إلى دخل
- offer_builder: 4 offers (Private Beta, 499 Pilot, Growth OS Pilot 1.5-3K, Free Case Study) + segment-aware recommend
- pipeline_tracker: 8-stage deterministic pipeline + add/update/summarize + revenue tracking + win rate
- outreach_sequence: re-export single source of truth from launch_ops with revenue-tier wrappers
- demo_closer: re-export from launch_ops
- pilot_delivery: 12-field intake form + 5-phase 24h delivery plan + per-service templates (First 10 / List Intel / Free Diagnostic)
- proof_pack_template: 5-line Arabic client summary + ROI estimate (pipeline_x + closed_won_x) + next-step recommendation (upsell/iterate/extend)
- payment_manual_flow: Moyasar invoice step-by-step (halalas-correct) + Arabic payment-link message + confirmation checklist; NEVER charges via API

Service Tower extensions (2 modules)
- contract_templates: re-export targeting_os contracts + new SLA outline (legal_review_required, PDPL-aware)
- vertical_service_map: 6 verticals (B2B SaaS / agencies / training-consulting / real estate / healthcare-local / retail-ecommerce) with primary+supporting services + buyer roles + common pains + winning offer

Routers (2 new) — 29 endpoints
- /api/v1/launch/* — 11 endpoints (private-beta/offer, demo/flow, outreach/{first-20, message, followup}, go-no-go, readiness, scorecard/{event, daily, weekly, demo})
- /api/v1/revenue-launch/* — 18 endpoints (offers + offers/recommend, outreach/{first-20, followup}, demo-flow, pipeline/{schema, summarize}, pilot-delivery/{intake-form, 24h-plan, first-10, list-intelligence, free-diagnostic}, payment/{invoice-instructions, link-message, confirmation-checklist}, proof-pack/{template, client-summary, next-step})

Tests (2 new files, 56 tests)
- test_launch_ops.py: 25 tests (Private Beta offer essentials + Arabic FAQ; demo flow 12-min structure; first-20 segments × 5; outreach Arabic + drafts only; followup steps differ; reply handlers include unsubscribe; go/no-go critical gates block; scorecard aggregation + verdict)
- test_revenue_launch.py: 31 tests (offers correct prices, no_live_charge=True; segment-aware recommends; pipeline 8 stages + add/update/summarize + win rate; outreach v2 Arabic; intake fields; 24h plan 5 phases; invoice halalas correct; payment confirmation blocks premature delivery; proof pack 5 lines + 3 next-step paths)

Scripts (1 new)
- scripts/launch_readiness_check.py: runs 10 gates locally + optional --staging-url; pretty/JSON output; critical gates determine GO/NO-GO/FIX-THEN-GO verdict

Landing pages (2 new, RTL Arabic)
- list-intelligence.html — List Intelligence service detail (499–1,500 SAR)
- growth-os.html — Growth OS Monthly subscription page (2,999 SAR/month)

Docs (1 new + 1 updated)
- REVENUE_TODAY_PLAYBOOK.md (Arabic) — 12-section playbook: offers, segments, messages, demo, pipeline, 24h delivery, Moyasar manual flow, proof pack, daily targets, go/no-go, what-not-to-do, next-step
- DEALIX_100_PERCENT_LAUNCH_PLAN.md — added §40 Launch Ops + §41 Revenue Launch + §42 Service Tower extensions + §43 Scripts

Test results
- 56/56 new tests pass
- Full suite: 824 passed, 2 skipped (missing API keys, unrelated)
- 0 existing tests broken

Safety integration
- All offers: live_send_allowed=False, no_live_charge=True, approval_required=True
- 10-gate go/no-go BLOCKS launch if no_secrets/live_sends_disabled/staging_health fail
- Moyasar: invoice/payment-link manual only; NEVER calls live charge API
- Payment confirmation checklist blocks delivery before invoice paid status
- All outreach messages: drafts only, follow-ups capped at 3, opt-out honored immediately
- 6 verticals mapped to safe service stacks; LinkedIn always Lead Forms (never scraping)

Integration with previous layers
- Launch Ops uses platform_services tool_gateway, intelligence_layer command_feed, security_curator redaction
- Revenue Launch uses targeting_os contractability + service_tower offers + intelligence_layer simulator
- Pipeline tracker integrates with action_ledger for stage transitions
- Proof Pack template references intelligence_layer proof metrics + service_excellence ROI

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 17:28:08 +03:00

205 lines
7.3 KiB
Python

"""Unit tests for Launch Ops."""
from __future__ import annotations
import pytest
from auto_client_acquisition.launch_ops import (
PRIVATE_BETA_OFFER,
build_12_min_demo_flow,
build_close_script,
build_daily_launch_scorecard,
build_discovery_questions,
build_first_20_segments,
build_followup_message,
build_launch_readiness,
build_objection_responses,
build_outreach_message,
build_private_beta_offer,
build_private_beta_safety_notes,
build_reply_handlers,
build_weekly_launch_scorecard,
decide_go_no_go,
private_beta_faq,
record_launch_event,
)
# ── Private Beta ─────────────────────────────────────────────
def test_private_beta_offer_has_essentials():
o = build_private_beta_offer()
assert o["price_sar"] == 499
assert o["duration_days"] == 7
assert o["live_send_allowed"] is False
assert o["approval_required"] is True
assert len(o["deliverables_ar"]) >= 4
def test_private_beta_offer_seats_override():
o = build_private_beta_offer(seats_remaining=2)
assert o["seats_available"] == 2
def test_private_beta_safety_notes_blocks_live():
s = build_private_beta_safety_notes()
text = " ".join(s["do_not_do_ar"])
assert "live" in text.lower() or "عشوائي" in text or "تلقائي" in text
assert any("PDPL" in line for line in s["do_not_do_ar"])
def test_private_beta_faq_arabic():
faq = private_beta_faq()
assert len(faq) >= 4
for item in faq:
assert any("؀" <= ch <= "ۿ" for ch in item["q_ar"])
assert any("؀" <= ch <= "ۿ" for ch in item["a_ar"])
# ── Demo Flow ────────────────────────────────────────────────
def test_demo_flow_is_12_minutes():
f = build_12_min_demo_flow()
assert f["duration_minutes"] == 12
assert len(f["minute_by_minute_ar"]) == 6
def test_demo_discovery_has_5_questions():
out = build_discovery_questions()
assert len(out) == 5
def test_objection_responses_cover_essentials():
out = build_objection_responses()
for k in ("price", "timing", "trust", "complexity", "data_privacy"):
assert k in out
def test_close_script_arabic():
out = build_close_script()
assert len(out["close_sequence_ar"]) >= 3
assert any("؀" <= ch <= "ۿ" for ch in out["close_template_ar"])
# ── Outreach ─────────────────────────────────────────────────
def test_first_20_has_4_segments_total_20():
out = build_first_20_segments()
assert out["total_targets"] == 20
assert len(out["segments"]) == 4
assert sum(s["count"] for s in out["segments"]) == 20
def test_outreach_message_is_arabic_and_drafts_only():
out = build_outreach_message("agency_b2b", name="أحمد")
assert any("؀" <= ch <= "ۿ" for ch in out["body_ar"])
assert out["live_send_allowed"] is False
def test_outreach_unknown_segment_falls_back():
out = build_outreach_message("totally_unknown", name="X")
assert out["body_ar"]
def test_followup_step_2_different_from_1():
s1 = build_followup_message("training_consulting", step=1, name="X")
s2 = build_followup_message("training_consulting", step=2, name="X")
assert s1["body_ar"] != s2["body_ar"]
def test_followup_step_3_archives():
s3 = build_followup_message("agency_b2b", step=3, name="X")
assert s3["kind"] == "followup_3_final"
def test_reply_handlers_include_critical():
h = build_reply_handlers()
for k in ("interested", "needs_more_info", "price_objection",
"not_now", "no_thanks", "unsubscribe"):
assert k in h
# ── Go / No-Go ───────────────────────────────────────────────
def test_readiness_all_false_returns_zero_pct():
r = build_launch_readiness(statuses={})
assert r["passed_pct"] == 0.0
assert r["passed_gates"] == 0
assert len(r["blockers_ar"]) == r["total_gates"]
def test_readiness_all_true_returns_full_pct():
statuses = {gate["id"]: True for gate in
__import__("auto_client_acquisition.launch_ops",
fromlist=["LAUNCH_GATES"]).go_no_go.LAUNCH_GATES}
r = build_launch_readiness(statuses=statuses)
assert r["passed_pct"] == 100.0
assert r["passed_gates"] == r["total_gates"]
def test_go_no_go_blocks_when_no_secrets_fails():
decision = decide_go_no_go(statuses={"tests_passed": True,
"routes_check": True,
"no_secrets": False,
"staging_health": True,
"live_sends_disabled": True})
assert decision["verdict"] == "no_go"
def test_go_no_go_blocks_when_live_sends_enabled():
decision = decide_go_no_go(statuses={"tests_passed": True,
"routes_check": True,
"no_secrets": True,
"staging_health": True,
"live_sends_disabled": False})
assert decision["verdict"] == "no_go"
def test_go_no_go_passes_with_critical_and_70pct():
statuses = {
"tests_passed": True, "routes_check": True, "no_secrets": True,
"staging_health": True, "supabase_staging": True,
"service_catalog": True, "private_beta_page": True,
"first_20_ready": True, "live_sends_disabled": True,
"payment_manual_ready": False, # 9/10 = 90%
}
decision = decide_go_no_go(statuses=statuses)
assert decision["verdict"] == "go"
# ── Scorecard ────────────────────────────────────────────────
def test_record_event_unknown_raises():
with pytest.raises(ValueError):
record_launch_event(event_type="totally_invalid")
def test_record_event_appends_to_log():
log: list = []
record_launch_event(event_type="outreach_sent", event_log=log)
assert len(log) == 1
assert log[0]["event_type"] == "outreach_sent"
def test_daily_scorecard_aggregates():
events = [{"event_type": "outreach_sent"}] * 12 + \
[{"event_type": "demo_booked"}] * 2
s = build_daily_launch_scorecard(events=events)
assert s["metrics"]["outreach_sent"] == 12
assert s["metrics"]["demo_booked"] == 2
assert s["progress"]["outreach_sent"]["pct"] == 60.0 # 12/20 = 60%
def test_weekly_scorecard_returns_verdict():
events = [{"event_type": "outreach_sent"}] * 50 + \
[{"event_type": "pilot_paid"}] * 2
s = build_weekly_launch_scorecard(events=events)
assert s["verdict"] == "on_track"
def test_weekly_scorecard_needs_focus_for_low_demos():
events = [{"event_type": "outreach_sent"}] * 5
s = build_weekly_launch_scorecard(events=events)
assert s["verdict"] == "needs_focus"
# ── Constants exposed ────────────────────────────────────────
def test_private_beta_offer_constant_exposed():
assert PRIVATE_BETA_OFFER["price_sar"] == 499
assert PRIVATE_BETA_OFFER["live_send_allowed"] is False