예제 #1
0
def test_usermode():
    """ MODE command """
    command = "USERMODE"
    expected_kwargs = {"nick": "nck", "host": "", "modes": "+x"}
    message = "MODE nck +x"
    assert (command, expected_kwargs) == unpack_command(message)
    expected_kwargs['user'] = '******'
    assert set(expected_kwargs) == set(parameters(command))
예제 #2
0
def test_usermode():
    """ MODE command """
    command = "USERMODE"
    expected_kwargs = {"nick": "nck", "host": "",
                       "modes": "+x"}
    message = "MODE nck +x"
    assert (command, expected_kwargs) == unpack_command(message)
    expected_kwargs['user'] = '******'
    assert set(expected_kwargs) == set(parameters(command))
예제 #3
0
def test_channelmode_plus():
    """ MODE command """
    command = "CHANNELMODE"
    expected_kwargs = {"channel": "+ch", "host": "",
                       "modes": "+o", "params": ['trget', 'trget2']}
    message = "MODE +ch +o trget trget2"
    assert (command, expected_kwargs) == unpack_command(message)
    expected_kwargs['user'] = '******'
    expected_kwargs['nick'] = 'nck'
    assert set(expected_kwargs) == set(parameters(command))
예제 #4
0
def test_channelmode_no_params():
    """ MODE command """
    command = "CHANNELMODE"
    expected_kwargs = {"channel": "#ch", "host": "",
                       "modes": "+m", "params": []}
    message = "MODE #ch +m"
    assert (command, expected_kwargs) == unpack_command(message)
    expected_kwargs['user'] = '******'
    expected_kwargs['nick'] = 'nck'
    assert set(expected_kwargs) == set(parameters(command))
예제 #5
0
def test_channelmode_plus():
    """ MODE command """
    command = "CHANNELMODE"
    expected_kwargs = {
        "channel": "+ch",
        "host": "",
        "modes": "+o",
        "params": ['trget', 'trget2']
    }
    message = "MODE +ch +o trget trget2"
    assert (command, expected_kwargs) == unpack_command(message)
    expected_kwargs['user'] = '******'
    expected_kwargs['nick'] = 'nck'
    assert set(expected_kwargs) == set(parameters(command))
예제 #6
0
def test_channelmode_no_params():
    """ MODE command """
    command = "CHANNELMODE"
    expected_kwargs = {
        "channel": "#ch",
        "host": "",
        "modes": "+m",
        "params": []
    }
    message = "MODE #ch +m"
    assert (command, expected_kwargs) == unpack_command(message)
    expected_kwargs['user'] = '******'
    expected_kwargs['nick'] = 'nck'
    assert set(expected_kwargs) == set(parameters(command))
예제 #7
0
def test_client_commands():
    ''' CLIENT_CONNECT and CLIENT_DISCONNECT '''
    expected = set(["host", "port"])
    assert expected == set(parameters("CLIENT_CONNECT"))
    assert expected == set(parameters("CLIENT_DISCONNECT"))
예제 #8
0
def validate(command, message, expected_kwargs):
    ''' Basic case - expected_kwargs expects all parameters of the command '''
    assert (command, expected_kwargs) == unpack_command(message)
    assert set(expected_kwargs) == set(parameters(command))
예제 #9
0
def test_unknown_command():
    ''' raise when command isn't known '''
    with pytest.raises(ValueError):
        unpack_command("unknown_command")
    with pytest.raises(ValueError):
        parameters("unknown_command")
예제 #10
0
def test_client_commands():
    """ CLIENT_CONNECT and CLIENT_DISCONNECT """
    expected = set(["host", "port"])
    assert expected == set(parameters("CLIENT_CONNECT"))
    assert expected == set(parameters("CLIENT_DISCONNECT"))
예제 #11
0
def validate(command, message, expected_kwargs):
    """ Basic case - expected_kwargs expects all parameters of the command """
    assert (command, expected_kwargs) == unpack_command(message)
    assert set(expected_kwargs) == set(parameters(command))
예제 #12
0
def test_unknown_command():
    """ raise when command isn't known """
    with pytest.raises(ValueError):
        unpack_command("unknown_command")
    with pytest.raises(ValueError):
        parameters("unknown_command")