from datetime import UTC, datetime from zerto_rewind_mcp.checkpoints import checkpoint_id, checkpoint_tag, make_tag def test_tag_format(): when = datetime(2026, 9, 21, 15, 4, 5, tzinfo=UTC) tag = make_tag("codex", "chg-99", when) assert tag == "ai:codex:chg-99:20260921T150405Z" def test_tag_strips_junk(): tag = make_tag("agent one", "path/with spaces", datetime(2026, 1, 1, tzinfo=UTC)) assert " " not in tag assert tag.startswith("ai:agent-one:path-with-spaces:") def test_checkpoint_row_keys(): row = {"CheckpointId": "cp-1", "Tag": "ai:x:y:z", "Timestamp": 1} assert checkpoint_id(row) == "cp-1" assert checkpoint_tag(row) == "ai:x:y:z" row2 = {"checkpointId": "cp-2", "tag": "t"} assert checkpoint_id(row2) == "cp-2" assert checkpoint_tag(row2) == "t"