def test_execute_not_exists_command(manager: ModuleManager): manager.execute_func = CoroutineMock() manager.find_message_in_db = CoroutineMock() manager.load_all() yield from manager.execute_command( cmd='szalona-dziewczyna', text='lol b=42', private=False, channel='#czarnobyl', user=User('a!b@c'), ) assert not manager.execute_func.called manager.find_message_in_db.assert_called_once_with( 'szalona-dziewczyna', '#czarnobyl', 'lol b=42', )
def test_execute_not_exists_command(manager: ModuleManager): manager.execute_func = CoroutineMock() manager.find_message_in_db = CoroutineMock() manager.load_all() yield from manager.execute_command( cmd='szalona-dziewczyna', text='lol b=42', private=False, channel='#czarnobyl', user=User('a!b@c'), ) assert not manager.execute_func.called manager.find_message_in_db.assert_called_once_with( 'szalona-dziewczyna', '#czarnobyl', 'lol b=42', )
def test_find_message_in_db(manager_with_db: ModuleManager): manager_with_db.load_all() with manager_with_db.protocol.get_session() as session: msg = Message() msg.channel = '#czarnobyl' msg.key = 'gjm' msg.message = '$0: $1gram juz miesiac; $@' session.add(msg) yield from manager_with_db.find_message_in_db( cmd='gjm', channel='#czarnobyl', text='lol kilo', ) assert manager_with_db.protocol.messages == [ SayMessage( '#czarnobyl', 'lol: kilogram juz miesiac; lol kilo', ) ]
def test_find_message_in_db(manager_with_db: ModuleManager): manager_with_db.load_all() with manager_with_db.protocol.get_session() as session: msg = Message() msg.channel = '#czarnobyl' msg.key = 'gjm' msg.message = '$0: $1gram juz miesiac; $@' session.add(msg) yield from manager_with_db.find_message_in_db( cmd='gjm', channel='#czarnobyl', text='lol kilo', ) assert manager_with_db.protocol.messages == [ SayMessage( '#czarnobyl', 'lol: kilogram juz miesiac; lol kilo', ) ]
def test_execute_command(manager: ModuleManager): manager.execute_func = CoroutineMock() manager.find_message_in_db = CoroutineMock() manager.load_all() yield from manager.execute_command( cmd='dummy', text='lol b=42', private=False, channel='#czarnobyl', user=User('a!b@c'), ) assert not manager.find_message_in_db.called from grazyna.test_mocks.dummy_plugin import dummy manager.execute_func.assert_called_once_with( dummy, manager.plugins['dummy'], False, '#czarnobyl', User('a!b@c'), ['lol'], {'b': '42'}, )
def test_execute_command(manager: ModuleManager): manager.execute_func = CoroutineMock() manager.find_message_in_db = CoroutineMock() manager.load_all() yield from manager.execute_command( cmd='dummy', text='lol b=42', private=False, channel='#czarnobyl', user=User('a!b@c'), ) assert not manager.find_message_in_db.called from grazyna.test_mocks.dummy_plugin import dummy manager.execute_func.assert_called_once_with( dummy, manager.plugins['dummy'], False, '#czarnobyl', User('a!b@c'), ['lol'], {'b': '42'}, )