#!/usr/bin/env python3
"""
Tests for pure-helper functions in the manage_marketing_version family.

Covers:
  - ``semver_tuple`` parsing edge cases.
  - ``bump_patch_for_message`` text used inside the build-setting error
    message.

Split out of ``test_manage_marketing_version.py`` (Issue 15: file
function-count cap) so each file groups tests by behaviour boundary.
``DecideForVersionTests`` remains in the original module since those
tests are the orchestrator's primary surface.
"""

from __future__ import annotations

import sys
import unittest
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parent))

import manage_marketing_version as mmv  # noqa: E402

from mmv_floor_check import bump_patch_for_message  # noqa: E402


class SemverParsingTests(unittest.TestCase):
    """Pure-function coverage: semver_tuple."""

    def test_semver_tuple_parses_three_part(self):
        self.assertEqual(mmv.semver_tuple("1.2.3"), (1, 2, 3))

    def test_semver_tuple_parses_two_part_as_zero_patch(self):
        self.assertEqual(mmv.semver_tuple("1.2"), (1, 2, 0))

    def test_semver_tuple_nonmatch_returns_sentinel(self):
        self.assertEqual(mmv.semver_tuple("beta"), (-1, -1, -1))
        self.assertEqual(mmv.semver_tuple(""), (-1, -1, -1))


class BumpPatchForMessageTests(unittest.TestCase):
    """Helper used in the build-setting error message text."""

    def test_bumps_three_part_patch(self):
        self.assertEqual(bump_patch_for_message("1.0.6"), "1.0.7")

    def test_treats_missing_patch_as_zero(self):
        self.assertEqual(bump_patch_for_message("1.2"), "1.2.1")

    def test_non_semver_returns_passthrough_hint(self):
        self.assertIn("foo", bump_patch_for_message("foo"))


if __name__ == "__main__":
    unittest.main()
