Пример #1
0
def test_execute_as_cmd_and_reply(manager: ModuleManager):
    manager.execute_command = CoroutineMock()
    yield from manager.execute('#czarnobyl', User('a!b@c'), 'bot: dummy lol')
    manager.execute_command.assert_called_once_with(
        'dummy',
        'lol',
        False,
        '#czarnobyl',
        User('a!b@c'),
    )
Пример #2
0
def test_execute_as_cmd_and_private(manager: ModuleManager):
    manager.execute_command = CoroutineMock()
    yield from manager.execute('socek', User('a!b@c'), '.dummy lol')
    manager.execute_command.assert_called_once_with(
        'dummy',
        'lol',
        True,
        'socek',
        User('a!b@c'),
    )
Пример #3
0
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',
    )
Пример #4
0
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',
    )
Пример #5
0
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'},
    )
Пример #6
0
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'},
    )
Пример #7
0
def test_execute_as_cmd_and_private(manager: ModuleManager):
    manager.execute_command = CoroutineMock()
    yield from manager.execute('socek', User('a!b@c'), '.dummy lol')
    manager.execute_command.assert_called_once_with(
        'dummy', 'lol', True, 'socek', User('a!b@c'),
    )
Пример #8
0
def test_execute_as_cmd_and_reply(manager: ModuleManager):
    manager.execute_command = CoroutineMock()
    yield from manager.execute('#czarnobyl', User('a!b@c'), 'bot: dummy lol')
    manager.execute_command.assert_called_once_with(
        'dummy', 'lol', False, '#czarnobyl', User('a!b@c'),
    )