from __future__ import annotations

from flatten_tree_files import build_plan, label_from_path


def test_label_from_path_uses_supplier_segment() -> None:
    assert label_from_path("2026.03/_by_supplier/domains-hosting/_no_account/Domeny.xlsx") == "domains-hosting"


def test_build_plan_skips_flat_files_and_avoids_existing_targets() -> None:
    paths = [
        "2026.03/2026.03.01-saas-existing.pdf",
        "2026.03/_by_supplier/domains-hosting/_no_account/Domeny.xlsx",
        "2026.03/_by_supplier/domains-hosting/info@softreck.com/Domeny.xlsx",
    ]
    seen = {"2026.03/2026.03.00-domains-hosting-Domeny.xlsx"}

    plan = build_plan(paths, seen=seen)

    assert [row["target"] for row in plan] == [
        "2026.03/2026.03.00-domains-hosting-Domeny-2.xlsx",
        "2026.03/2026.03.00-domains-hosting-Domeny-3.xlsx",
    ]
