#!/usr/bin/env python3
"""Regression tests for closeout.py helpers."""

from __future__ import annotations

import argparse
import datetime as dt

import closeout


def test_slugify() -> None:
    assert closeout.slugify("Codex Plugin Closeout Fix!") == "codex-plugin-closeout-fix"


def test_session_log_render_uses_codex_client_and_related_links() -> None:
    args = argparse.Namespace(
        slug="codex-plugin-closeout-fix",
        goal="Implement closeout helper.",
        actions="Added closeout.py.",
        next_step="Start a new thread to load the patched plugin.",
        daily_line="Implemented closeout helper.",
        related=["[[_agent/skills/active/echo-memory-codex-plugin]]"],
        notes_read=[],
        outputs=["`closeout.py` - session closeout helper"],
        decisions=[],
        open_threads=[],
    )
    body = closeout.render_session_log(
        args,
        dt.datetime(2026, 6, 20, 5, 45),
        "_agent/sessions/2026-06-20-0545-codex-plugin-closeout-fix.md",
    )
    assert "client: codex" in body
    assert "[[_agent/skills/active/echo-memory-codex-plugin]]" in body
    assert "Session path:" in body


if __name__ == "__main__":
    test_slugify()
    test_session_log_render_uses_codex_client_and_related_links()
    print("test_closeout: ok")
