"""Tests for caffeinate_me.quotes."""

import pytest

from caffeinate_me.quotes import (
    AFTERNOON,
    DARK_HUMOR,
    EVENING,
    MORNING,
    MOTIVATIONAL,
    PROGRAMMER,
    SARCASTIC,
    WHOLESOME,
    get_all_quotes,
    get_quotes_by_category,
    get_random_quote,
)


class TestQuoteLibrary:
    def test_motivational_size(self):
        assert len(MOTIVATIONAL) >= 15

    def test_sarcastic_size(self):
        assert len(SARCASTIC) >= 15

    def test_programmer_size(self):
        assert len(PROGRAMMER) >= 15

    def test_wholesome_size(self):
        assert len(WHOLESOME) >= 10

    def test_dark_humor_size(self):
        assert len(DARK_HUMOR) >= 5

    def test_morning_size(self):
        assert len(MORNING) >= 5

    def test_afternoon_size(self):
        assert len(AFTERNOON) >= 5

    def test_evening_size(self):
        assert len(EVENING) >= 5

    def test_total_count_exceeds_fifty(self):
        assert len(get_all_quotes()) >= 50

    def test_all_quotes_are_non_empty_strings(self):
        for q in get_all_quotes():
            assert isinstance(q, str)
            assert q.strip()

    def test_no_duplicate_quotes(self):
        all_q = get_all_quotes()
        assert len(all_q) == len(set(all_q)), "Duplicate quotes found"


class TestGetRandomQuote:
    def test_returns_non_empty_string(self):
        result = get_random_quote()
        assert isinstance(result, str) and result.strip()

    @pytest.mark.parametrize("mood", ["energetic", "sleepy", "stressed", "zen"])
    def test_mood_returns_string(self, mood):
        assert isinstance(get_random_quote(mood=mood), str)

    def test_unknown_mood_falls_back_to_time_of_day(self):
        result = get_random_quote(mood="turbo_diesel")
        assert isinstance(result, str) and result.strip()

    def test_produces_variety(self):
        results = {get_random_quote() for _ in range(30)}
        assert len(results) > 1


class TestGetQuotesByCategory:
    @pytest.mark.parametrize(
        "category",
        ["motivational", "sarcastic", "programmer", "wholesome", "dark_humor",
         "morning", "afternoon", "evening"],
    )
    def test_known_categories(self, category):
        quotes = get_quotes_by_category(category)
        assert isinstance(quotes, list)
        assert len(quotes) > 0

    def test_unknown_category_returns_empty(self):
        assert get_quotes_by_category("existential_dread") == []
