def check_admin_input(n): """Tests admin with incorrect password""" line = parser.partition_raw(":StealthyLoner!foo@bar PRIVMSG SLPyBot :foo foo") response = parser.admin_input(line) if n > 0: assert response[0] == ('send_data', 'PRIVMSG StealthyLoner :You have been configured as admin, but you did not provide the correct password') assert response[1] == ('send_data', 'PRIVMSG StealthyLoner :You have ' + str(n) + ' tries left.') else: assert response[0] == ('send_data', 'PRIVMSG StealthyLoner :Sorry :(')
def test_partition_raw02(): """Tests ircnet style server message""" line = parser.partition_raw(":irc.server.foo 042 username some attributes :human readable message") assert line['name'] == 'irc.server.foo' assert line['user'] == None assert line['host'] == None assert line['command'] == '042' assert line['middle'] == 'username' assert line['trailing'] == 'some attributes :human readable message'
def test_partition_raw01(): """Tests full and correctly formed message""" line = parser.partition_raw(":name!user@host command middle :rest of the message") assert line['name'] == 'name' assert line['user'] == 'user' assert line['host'] == 'host' assert line['command'] == 'command' assert line['middle'] == 'middle' assert line['trailing'] == 'rest of the message'
def test_server_input(): line = parser.partition_raw(":irc.foobar.net 001 foobar :Welcome") response = parser.server_input(line) assert response == [('set_registered', True)] line = parser.partition_raw(":irc.foobar.net 403 foobar :No such channel") response = parser.server_input(line) assert response == [None] line = parser.partition_raw(":irc.foobar.net 405 foobar :Too many channels") response = parser.server_input(line) assert response == [None] line = parser.partition_raw(":irc.foobar.net 471 foobar :Channel limit reached") response = parser.server_input(line) assert response == [None] line = parser.partition_raw(":irc.foobar.net 473 foobar :Channel is invite only") response = parser.server_input(line) assert response == [None] line = parser.partition_raw(":irc.foobar.net 474 foobar :You are banned from the channel") response = parser.server_input(line) assert response == [None] line = parser.partition_raw(":irc.foobar.net 432 foobar :foobar") response = parser.server_input(line) assert response[0][0] == 'set_nick' line = parser.partition_raw(":irc.foobar.net 433 foobar :foobar") response = parser.server_input(line) assert response[0][0] == 'set_nick' line = parser.partition_raw(":irc.foobar.net 421 foobar :Unknown command") response = parser.server_input(line) assert response == [None] line = parser.partition_raw(":irc.foobar.net 000 foobar :Numerical not in list") response = parser.server_input(line) assert response == [None]
def test_own_input_blank(): line = parser.partition_raw(":SLPyBot!foo@bar PRIVMSG #channel :foobar") response = parser.own_input(line) assert response == [None]
def test_own_input_part(): line = parser.partition_raw(":SLPyBot!foo@bar PART #test_channel :part message") response = parser.own_input(line) assert response == [('remove_ircchannel', '#test_channel')]
def test_own_input_join(): line = parser.partition_raw(":SLPyBot!foo@bar JOIN :#test_channel") response = parser.own_input(line) assert response == [('add_ircchannel', '#test_channel')]
def test_admin_input_no_command(): """Tests admin with no command""" line = parser.partition_raw(":StealthyLoner!foo@bar PRIVMSG SLPyBot :mummo123") response = parser.admin_input(line) assert response == [('send_data', 'PRIVMSG StealthyLoner :Please provide a command')]
def test_admin_input_incorrect_admin(): """Tests admin with incorrect name""" line = parser.partition_raw(":foobar!foo@bar PRIVMSG SLPyBot :mummo123 foo") response = parser.admin_input(line) assert response == [('send_data', 'PRIVMSG foobar :This operation is not allowed by you')]
def test_ctcp_input(): """Tests CTCP input with no handlers""" line = parser.partition_raw(":foo!foo@bar PRIVMSG foobar :CTCP") response = parser.ctcp_input(line) assert response == []
def test_channel_input_no_handler(): """Tests channel input with no handlers""" line = parser.partition_raw(":foo!foo@bar PRIVMSG foobar :foo") response = parser.channel_input(line) assert response == []
def test_notice_input_no_handler(): """Tests notice with no handlers""" line = parser.partition_raw(":foo!foo@bar NOTICE foobar :foo") response = parser.notice_input(line) assert response == []