def __init__(self, bot): self.bot = bot # One time events that we only need to register temporarily self.before_connect_events = [ event.event(event.NOTICE, callback=self.check_login), event.event(event.RPL_ENDOFMOTD, callback=self.remove_events), event.event(event.GLOBALUSERSTATE, callback=self.set_user_state) ]
def test___init__(self): func = lambda x: x instance = event.event('ABC', callback=func) assert instance.callback == func
def test_compile_no_config(self): func = lambda x: x decorated = event.event(r'\S+')(func) matcher = decorated.compile() assert matcher('ABC') is not None assert matcher('ABC ') is None
def test_raw_event(self): func = lambda x: x decorated = event.event(event.PRIVMSG)(func) assert decorated.key == event.PRIVMSG.re
def test_regexp(self): func = lambda x: x decorated = event.event('ABC')(func) assert decorated.regexp == 'ABC'
def test_decorator(self): func = lambda x: x instance = event.event('ABC') assert instance.callback is None decorated = instance(func) assert decorated.callback == func