def test_unknown_type_submission(self, bot):
        submission = SubmissionBuilder(file_ext="zzz", file_size=47453).build_full_submission()
        chat_id = -9327622
        message_id = 2873292

        try:
            submission.send_message(bot, chat_id, message_id)
            assert False, "Should have thrown exception."
        except CantSendFileType as e:
            assert str(e) == "I'm sorry, I don't understand that file extension (zzz)."
    def test_swf_submission(self, bot):
        submission = SubmissionBuilder(file_ext="swf", file_size=47453).build_full_submission()
        chat_id = -9327622
        message_id = 2873292

        try:
            submission.send_message(bot, chat_id, message_id)
            assert False, "Should have thrown exception."
        except CantSendFileType as e:
            assert str(e) == "I'm sorry, I can't neaten \".swf\" files."
    def test_send_message__without_prefix(self, bot):
        submission = SubmissionBuilder(file_ext="jpg", file_size=FASubmission.SIZE_LIMIT_IMAGE - 1)\
            .build_full_submission()
        chat_id = -9327622
        message_id = 2873292

        submission.send_message(bot, chat_id, message_id)

        bot.send_photo.assert_called_once()
        assert bot.send_photo.call_args[1]['chat_id'] == chat_id
        assert bot.send_photo.call_args[1]['photo'] == submission.download_url
        assert bot.send_photo.call_args[1]['caption'] == submission.link
        assert bot.send_photo.call_args[1]['reply_to_message_id'] == message_id
    def test_pdf_submission(self, bot):
        submission = SubmissionBuilder(file_ext="gif", file_size=47453).build_full_submission()
        chat_id = -9327622
        message_id = 2873292

        submission.send_message(bot, chat_id, message_id)

        bot.send_photo.assert_not_called()
        bot.send_document.assert_called_once()
        assert bot.send_document.call_args[1]['chat_id'] == chat_id
        assert bot.send_document.call_args[1]['document'] == submission.download_url
        assert bot.send_document.call_args[1]['caption'] == submission.link
        assert bot.send_document.call_args[1]['reply_to_message_id'] == message_id
    def test_auto_doc_just_under_size_limit(self, bot):
        submission = SubmissionBuilder(file_ext="gif", file_size=FASubmission.SIZE_LIMIT_DOCUMENT - 1)\
            .build_full_submission()
        chat_id = -9327622
        message_id = 2873292

        submission.send_message(bot, chat_id, message_id)

        bot.send_document.assert_called_once()
        bot.send_photo.assert_not_called()
        bot.send_message.assert_not_called()
        assert bot.send_document.call_args[1]['chat_id'] == chat_id
        assert bot.send_document.call_args[1]['document'] == submission.download_url
        assert bot.send_document.call_args[1]['caption'] == submission.link
        assert bot.send_document.call_args[1]['reply_to_message_id'] == message_id
    def test_image_over_document_size_limit(self, bot):
        submission = SubmissionBuilder(file_ext="jpg", file_size=FASubmission.SIZE_LIMIT_DOCUMENT + 1)\
            .build_full_submission()
        chat_id = -9327622
        message_id = 2873292

        submission.send_message(bot, chat_id, message_id)

        bot.send_photo.assert_called_once()
        assert bot.send_photo.call_args[1]['chat_id'] == chat_id
        assert bot.send_photo.call_args[1]['photo'] == submission.thumbnail_url
        assert bot.send_photo.call_args[1]['caption'] == \
            f"{submission.link}\n[Direct download]({submission.download_url})"
        assert bot.send_photo.call_args[1]['reply_to_message_id'] == message_id
        assert bot.send_photo.call_args[1]['parse_mode'] == telegram.ParseMode.MARKDOWN
    def test_txt_submission(self, bot):
        submission = SubmissionBuilder(file_ext="txt").build_full_submission()
        chat_id = -9327622
        message_id = 2873292

        submission.send_message(bot, chat_id, message_id)

        bot.send_message.assert_not_called()
        bot.send_photo.assert_called_once()
        bot.send_document.assert_not_called()
        bot.send_audio.assert_not_called()
        assert bot.send_photo.call_args[1]['chat_id'] == chat_id
        assert bot.send_photo.call_args[1]['photo'] == submission.full_image_url
        assert bot.send_photo.call_args[1]['caption'] == \
            f"{submission.link}\n[Direct download]({submission.download_url})"
        assert bot.send_photo.call_args[1]['reply_to_message_id'] == message_id
        assert bot.send_photo.call_args[1]['parse_mode'] == telegram.ParseMode.MARKDOWN