def parse_line(self, line): prefix, command, parameters = parse_message(line) return Message(self, prefix, command, parameters)
def test_parse_without_trailing(): assert parse_message(':localhost 001 Welcome.') \ == ['localhost', '001', ['Welcome.']] assert parse_message(':localhost FURRFU abc:def') \ == ['localhost', 'FURRFU', ['abc:def']]
def test_parse_with_trailing(): assert parse_message(':localhost PRIVMSG #cafeen :!lart Bender') \ == ['localhost', 'PRIVMSG', ['#cafeen', '!lart Bender']] assert parse_message(':localhost KICK #cafeen kirkeby : Uuuuuud!') \ == ['localhost', 'KICK', ['#cafeen', 'kirkeby', ' Uuuuuud!']]
def test_parse_prefixless(): assert parse_message('PING 42') \ == [None, 'PING', ['42']] assert parse_message('ERROR :Closing connection') \ == [None, 'ERROR', ['Closing connection']]