async def test_on_join(test_db): listener = IRCListener(None, "chitanda", "irc.freenode.fake") listener.nickname = "chitanda" listener.on_join = AsyncMock(return_value=True) await on_join(listener, "#channel", "chitanda") with database() as (conn, cursor): cursor.execute(""" SELECT 1 FROM irc_channels WHERE name = "#channel" AND server = "irc.freenode.fake" AND active = 1 """) assert cursor.fetchone()
async def test_on_join_other_user(test_db): listener = IRCListener(None, 'chitanda', 'irc.freenode.fake') listener.nickname = 'chitanda' listener.on_join = coroutine(lambda *args: True) await on_join(listener, '#channel', 'azul') with database() as (conn, cursor): cursor.execute( """ SELECT 1 FROM irc_channels WHERE name = "#channel" AND server = "irc.freenode.fake" AND active = 1 """ ) assert not cursor.fetchone()