diff --git a/tests/modules/test_lmgtfy.py b/tests/modules/test_lmgtfy.py new file mode 100644 index 0000000..17cca1d --- /dev/null +++ b/tests/modules/test_lmgtfy.py @@ -0,0 +1,16 @@ +import pytest +from tests.lib import * # NOQA - fixtures + + +@pytest.fixture +def googbot(fakebot): + """ + Provide a bot loaded with the LMGTFY module + """ + fakebot.loadmodule("LMGTFY") + return fakebot + + +def test_lmgtfy_basic(googbot): + googbot.feed_line(".lmgtfy foobar asdf") + googbot.act_PRIVMSG.assert_called_once_with('#test', 'chatter: http://lmgtfy.com/?q=foobar+asdf') diff --git a/tests/modules/test_tell.py b/tests/modules/test_tell.py new file mode 100644 index 0000000..140511a --- /dev/null +++ b/tests/modules/test_tell.py @@ -0,0 +1,42 @@ +import pytest +from contextlib import closing +from tests.lib import * # NOQA - fixtures + + +@pytest.fixture +def tellbot(fakebot): + """ + Provide a bot loaded with the Calc module. Clear the database. + """ + fakebot.botconfig["module_configs"]["Tell"] = {"max": 10, "maxage": 2678400} + fakebot.loadmodule("SQLite") + with closing(fakebot.moduleInstances["SQLite"].opendb("tell.db")) as db: + db.query("DROP TABLE tells;") + fakebot.loadmodule("Tell") + return fakebot + + +def test_addtell(tellbot): + tellbot.feed_line(".tell fudge foo") + tellbot.act_PRIVMSG.assert_called_once_with("#test", "chatter: I'll pass that along.") + tellbot.act_PRIVMSG.reset_mock() + + +def test_gettell(tellbot): + test_addtell(tellbot) + tellbot.feed_line(".", sender=("fudge", "user", "host")) + tellbot.act_PRIVMSG.assert_called_once_with("#test", "fudge: chatter said 0 minutes ago: foo") + + +def test_tellhelp(tellbot): + tellbot.feed_line(".tell") + tellbot.act_PRIVMSG.assert_called_once_with("#test", "chatter: .tell - Tell someone something the next time they're seen. Example: .tell antiroach Do your homework!") + + +def test_max(tellbot): + for _ in range(0, 10): + tellbot.feed_line(".tell foobar asdf") + tellbot.act_PRIVMSG.reset_mock() + tellbot.feed_line(".tell foobar asdf") + tellbot.act_PRIVMSG.assert_not_called() +