# Path: grazyna/tests/commands/base.py
# def execute_message(protocol, data):
#     ctrl = MessageController(protocol, data)
#     ctrl.log = Mock()
#     ctrl.execute_message()
#     return ctrl
# 
# Path: grazyna/test_mocks/sender.py
# class Message(list):
# 
#     def __init__(self, *args):
#         arg, *args = args
#         super().__init__([arg.upper()] + args)


from grazyna.tests.commands.base import execute_message
from grazyna.test_mocks.sender import Message
import pytest


data = [':irc.server.net', '005', 'bot', 'CHANTYPES=#', 'NICKLEN=30']


def test_start_if_is_started(protocol):
    protocol.ready = True
    execute_message(protocol, data)
    assert protocol.messages == []


@pytest.mark.asyncio
def test_start_if_is_not_started(protocol):
    yield from []  # noqa - turn on global event_loop
    protocol.ready = False
    protocol.config['main']['channels'] = '#foo, #baar'
    execute_message(protocol, data)
    assert protocol.ready is True
    assert protocol.messages == [
        Message('JOIN', '#foo'),

# Path: grazyna/tests/commands/base.py
# def execute_message(protocol, data):
#     ctrl = MessageController(protocol, data)
#     ctrl.log = Mock()
#     ctrl.execute_message()
#     return ctrl
# 
# Path: grazyna/test_mocks/sender.py
# class Message(list):
# 
#     def __init__(self, *args):
#         arg, *args = args
#         super().__init__([arg.upper()] + args)


# Path: grazyna/tests/commands/test_command_start.py
from grazyna.tests.commands.base import execute_message
from grazyna.test_mocks.sender import Message
import pytest



data = [':irc.server.net', '005', 'bot', 'CHANTYPES=#', 'NICKLEN=30']


def test_start_if_is_started(protocol):
    protocol.ready = True
    execute_message(protocol, data)
    assert protocol.messages == []


@pytest.mark.asyncio
def test_start_if_is_not_started(protocol):
    yield from []  # noqa - turn on global event_loop
    protocol.ready = False
    protocol.config['main']['channels'] = '#foo, #baar'
    execute_message(protocol, data)
    assert protocol.ready is True
    assert protocol.messages == [
        Message('JOIN', '#foo'),

        Message('JOIN', '#baar'),