async def test_on_part_other_user(test_db): listener = IRCListener(None, "chitanda", "irc.freenode.fake") listener.nickname = "chitanda" listener.on_part = AsyncMock(return_value=True) with database() as (conn, cursor): cursor.execute(""" INSERT INTO irc_channels (name, server) VALUES ("#channel", "irc.freenode.fake") """) conn.commit() await on_part(listener, "#channel", "azul", None) 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_part_other_user(test_db): listener = IRCListener(None, 'chitanda', 'irc.freenode.fake') listener.nickname = 'chitanda' listener.on_part = coroutine(lambda *args: True) with database() as (conn, cursor): cursor.execute( """ INSERT INTO irc_channels (name, server) VALUES ("#channel", "irc.freenode.fake") """ ) conn.commit() await on_part(listener, '#channel', 'azul', None) cursor.execute( """ SELECT 1 FROM irc_channels WHERE name = "#channel" AND server = "irc.freenode.fake" AND active = 1 """ ) assert cursor.fetchone()