from dataclasses import dataclass import pytest from hebdobot import HebdoBot from tests import settings OWNER = "me" SENDER = "foobar" @dataclass class Answer(): target: str message: str @dataclass class Source(): nick: str class Event(): def __init__(self, target, nick, message): self.target = target self.source = Source(nick) self.arguments = [message] def test_privmsg(self, target, message): self.answers.append(Answer(target, message)) def test_public_message(self, target, sender, message): self.answers = [] self.on_pubmsg(None, Event(target, sender, message)) def test_private_message(self, target, sender, message): self.answers = [] self.on_privmsg(None, Event(target, sender, message)) @pytest.fixture def bot(): HebdoBot.test_public_message = test_public_message HebdoBot.test_private_message = test_private_message HebdoBot.test_privmsg = test_privmsg hebdobot = HebdoBot(settings) hebdobot.connection.privmsg = hebdobot.test_privmsg hebdobot.answers = [] return hebdobot