コード例 #1
0
ファイル: test_example.py プロジェクト: allesctf/2020
def test_module_bmi():
    from pyfibot.modules import module_bmi

    bot = bot_mock.BotMock()
    eq_(
        ("#channel", "your bmi is 27.76 which is overweight (from 25 to 30)"),
        module_bmi.command_bmi(bot, None, "#channel", "175/85"),
    )
コード例 #2
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from nose.tools import eq_
import bot_mock
from pyfibot.modules import module_urltitle
from utils import check_re

bot = bot_mock.BotMock()

lengh_str_regex = '\d+(h|m|s)(\d+(m))?(\d+s)?'
views_str_regex = '\d+(\.\d+)?(k|M|Billion|Trillion)?'
age_str_regex = '(FRESH|(\d+(\.\d+)?(y|d) ago))'


def test_imdb_ignore():
    msg = "http://www.imdb.com/title/tt1772341/"
    module_urltitle.init(bot)
    eq_(None, module_urltitle.handle_url(bot, None, "#channel", msg, msg))


def test_spotify_ignore():
    msg = "http://open.spotify.com/artist/4tuiQRw9bC9HZhSFJEJ9Mz"
    module_urltitle.init(bot)
    eq_(None, module_urltitle.handle_url(bot, None, "#channel", msg, msg))


def test_manual_ignore():
    msg = "- foofoo http://www.youtube.com/"
    module_urltitle.init(bot)
    eq_(None, module_urltitle.handle_url(bot, None, "#channel", msg, msg))
コード例 #3
0
ファイル: test_urltitle.py プロジェクト: vesatoivonen/pyfibot
def botmock():
    bot = bot_mock.BotMock()
    module_urltitle.init(bot)
    return bot
コード例 #4
0
ファイル: test_example.py プロジェクト: slagerfin/pyfibot
def test_botmock():
    bot = bot_mock.BotMock()
    eq_(('#channel', 'Foo'), bot.say("#channel", "Foo"))
コード例 #5
0
# -*- coding: utf-8 -*-
from nose.tools import eq_
import bot_mock
from pyfibot.modules import module_wolfram_alpha
from utils import check_re

config = {
    "module_wolfram_alpha": {
        "appid": "3EYA3R-WVR6GJQWLH"
    }
}  # unit-test only APPID, do not abuse kthxbai

bot = bot_mock.BotMock(config=config)


def test_simple():
    module_wolfram_alpha.init(bot)
    query = "42"
    # Wolfram Alpha seems to randomly return also Roman numerals
    regex = u"(42 = forty-two|forty-two = XLII)"
    result = module_wolfram_alpha.command_wa(bot, None, "#channel", query)[1]
    check_re(regex, result)


def test_complex():
    query = "answer to the life universe and everything"
    target = (
        "#channel",
        u"Answer to the Ultimate Question of Life, the Universe, and Everything = 42 | (according to Douglas Adams' humorous science-fiction novel The Hitchhiker's Guide to the Galaxy)"
    )
    result = module_wolfram_alpha.command_wa(bot, None, "#channel", query)
コード例 #6
0
ファイル: test_example.py プロジェクト: allesctf/2020
def test_botmock():
    bot = bot_mock.BotMock({})
    eq_(("#channel", "Foo"), bot.say("#channel", "Foo"))