import os
import sys

HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(HERE, "..", "scripts"))

import mlo_extractor


def test_parse_objectives_extracts_verb_and_object_phrase():
    result = mlo_extractor.parse_objectives(["Analyze policy tradeoffs."])

    assert result == [{
        "text": "Analyze policy tradeoffs.",
        "verb": "analyze",
        "bloom_level": "Analyze",
        "object_phrase": "policy tradeoffs",
    }]


def test_parse_objectives_classifies_bloom_level_after_prefix_and_leadin():
    result = mlo_extractor.parse_objectives([
        "M1.2: Students will be able to evaluate competing interventions."
    ])

    assert result[0]["verb"] == "evaluate"
    assert result[0]["bloom_level"] == "Evaluate"
    assert result[0]["object_phrase"] == "competing interventions"


def test_parse_objectives_empty_input_returns_empty_list():
    assert mlo_extractor.parse_objectives([]) == []


def test_parse_objectives_handles_no_clear_verb():
    result = mlo_extractor.parse_objectives(["Systems thinking and policy tradeoffs."])

    assert result[0]["verb"] == ""
    assert result[0]["bloom_level"] == "Unknown"
    assert result[0]["object_phrase"] == "Systems thinking and policy tradeoffs"
