# Path: deepanimebot/messages.py
# class Messages(object):
# class StatusMessages(Messages):
# class DMMessages(Messages):
#     def took_too_long():
#     def something_went_wrong():
#     def not_an_image():
#     def unknown_image():
#     def my_guess(cls, y, top_n=3, max_length=None, preface="Probable Anime:"):
#     def give_me_an_image():
#     def give_me_an_image():


import deploy
from deepanimebot import messages
# -*- coding: utf-8 -*-


def test_my_guess_honors_max_length_by_truncating_longest():
    y = [
        deploy.Prediction(2, '567890', 0.024),
        deploy.Prediction(7, '012', 0.046),
    ]
    # before truncation:
    # '\n2. 567890 2.40%\n7. 012 4.60%'
    max_length = 26
    reply = messages.Messages.my_guess(y, preface='', max_length=max_length)
    assert reply == '\n2. 567 2.40%\n7. 012 4.60%'
    assert len(reply) <= max_length


def test_my_guess_honors_max_length_by_truncating_all():
    y = [
        deploy.Prediction(2, '567', 0.091),
        deploy.Prediction(4, '789', 0.012),
    ]
    # before truncation:
    # '\n2. 567 9.10%\n4. 789 1.20%'
    max_length = 22

# Path: deepanimebot/messages.py
# class Messages(object):
# class StatusMessages(Messages):
# class DMMessages(Messages):
#     def took_too_long():
#     def something_went_wrong():
#     def not_an_image():
#     def unknown_image():
#     def my_guess(cls, y, top_n=3, max_length=None, preface="Probable Anime:"):
#     def give_me_an_image():
#     def give_me_an_image():


# Path: tests/test_deepanimebot_messages.py
import deploy
from deepanimebot import messages

# -*- coding: utf-8 -*-


def test_my_guess_honors_max_length_by_truncating_longest():
    y = [
        deploy.Prediction(2, '567890', 0.024),
        deploy.Prediction(7, '012', 0.046),
    ]
    # before truncation:
    # '\n2. 567890 2.40%\n7. 012 4.60%'
    max_length = 26
    reply = messages.Messages.my_guess(y, preface='', max_length=max_length)
    assert reply == '\n2. 567 2.40%\n7. 012 4.60%'
    assert len(reply) <= max_length


def test_my_guess_honors_max_length_by_truncating_all():
    y = [
        deploy.Prediction(2, '567', 0.091),
        deploy.Prediction(4, '789', 0.012),
    ]
    # before truncation:
    # '\n2. 567 9.10%\n4. 789 1.20%'
    max_length = 22

    reply = messages.Messages.my_guess(y, preface='', max_length=max_length)