from autoshorts.retention import score_hook, score_idea_retention


def test_score_hook_rewards_specific_tension_and_direct_address():
    weak = score_hook("Here are some productivity tips")
    strong = score_hook("If your brain has 47 tabs open, do this before opening TikTok.")

    assert strong["score"] > weak["score"]
    assert "specificity" in strong["signals"]
    assert "direct_address" in strong["signals"]
    assert "open_loop" in strong["signals"]


def test_score_idea_retention_penalizes_slow_generic_intros():
    idea = {
        "hook": "In this video I will talk about productivity tips.",
        "duration_seconds": 75,
        "visual_concept": "Static slideshow with abstract background.",
        "script_outline": "Some generic advice about habits and routines.",
        "cta": "Follow for more.",
    }

    result = score_idea_retention(idea)

    assert result["score"] < 7
    assert "slow_intro" in result["risks"]
    assert "generic_value" in result["risks"]


def test_score_idea_retention_accepts_strong_testbatch_candidate():
    idea = {
        "hook": "You do not need more discipline. You need a smaller first step.",
        "duration_seconds": 38,
        "visual_concept": "Pattern interrupt: messy desk becomes one tiny next action with timer and captions.",
        "script_outline": "Challenge the discipline myth, show the two-minute starter, give one concrete example, close the loop.",
        "cta": "Comment START if you want the template.",
    }

    result = score_idea_retention(idea)

    assert result["score"] >= 8
    assert not result["risks"]
