from django.test import SimpleTestCase
from unittest.mock import MagicMock

from apps.lyric.models import Token


class CoinTooltipTest(SimpleTestCase):
    def setUp(self):
        self.coin = Token ()
        self.coin.token_type = Token.COIN
        self.coin.expires_at = None

    def test_tooltip_contains_name(self):
        self.assertIn("Coin-on-a-String", self.coin.tooltip_text())

    def test_tooltip_contains_entry(self):
        self.assertIn("Admit 1 Entry", self.coin.tooltip_text())

    def test_tooltip_contains_reuse_description(self):
        self.assertIn("and another after that", self.coin.tooltip_text())

    def test_tooltip_contains_no_expiry(self):
        self.assertIn("no expiry", self.coin.tooltip_text())

class FreeTokenTooltipTest(SimpleTestCase):
    def setUp(self):
        self.token = Token()
        self.token.token_type = Token.FREE
        self.token.expires_at = MagicMock()
        self.token.expires_at.strftime = lambda fmt: "2026-03-15"

    def test_tooltip_contains_name(self):
        self.assertIn("Free Token", self.token.tooltip_text())

    def test_tooltip_contains_entry(self):
        self.assertIn("Admit 1 Entry", self.token.tooltip_text())

    def test_tooltip_contains_expires(self):
        self.assertIn("Expires", self.token.tooltip_text())

    def test_tooltip_contains_expiry_date(self):
        self.assertIn("2026-03-15", self.token.tooltip_text())


class PassTokenTooltipTest(SimpleTestCase):
    def setUp(self):
        self.token = Token()
        self.token.token_type = Token.PASS
        self.token.expires_at = None
        self.token.next_ready_at = None

    def test_tooltip_contains_name(self):
        self.assertIn("Backstage Pass", self.token.tooltip_text())

    def test_tooltip_contains_no_expiry(self):
        self.assertIn("no expiry", self.token.tooltip_text())


class BandTokenTooltipTest(SimpleTestCase):
    """Wristband mirrors PASS's "Admit All Entry" / never-expires shape but
    is non-admin (no `is_staff` gate). Tooltip prose is the only place the
    two diverge — different title + shoptalk."""

    def setUp(self):
        self.token = Token()
        self.token.token_type = Token.BAND
        self.token.expires_at = None
        self.token.next_ready_at = None

    def test_tooltip_contains_name(self):
        self.assertIn("Wristband", self.token.tooltip_text())

    def test_tooltip_contains_admit_all(self):
        self.assertIn("Admit All Entry", self.token.tooltip_text())

    def test_tooltip_contains_shoptalk(self):
        self.assertIn("Unlimited free entry", self.token.tooltip_text())
        self.assertIn("BYOB", self.token.tooltip_text())

    def test_tooltip_contains_no_expiry(self):
        self.assertIn("no expiry", self.token.tooltip_text())


class CarteTooltipTest(SimpleTestCase):
    def setUp(self):
        self.token = Token()
        self.token.token_type = Token.CARTE
        self.token.expires_at = None

    def test_tooltip_contains_name(self):
        self.assertIn("Carte Blanche", self.token.tooltip_text())

    def test_tooltip_contains_entry(self):
        self.assertIn("Admit up to +6", self.token.tooltip_text())

    def test_tooltip_contains_shoptalk(self):
        self.assertIn("taking over from here", self.token.tooltip_text())

    def test_tooltip_contains_no_expiry(self):
        self.assertIn("no expiry", self.token.tooltip_text())


class TitheTooltipTest(SimpleTestCase):
    def setUp(self):
        self.token = Token()
        self.token.token_type = Token.TITHE
        self.token.expires_at = None

    def test_tooltip_shoptalk_returns_none(self):
        self.assertIsNone(self.token.tooltip_shoptalk())
