def test_add_user(self): chan = Channel('#foobar') usr = User('nick', '*****@*****.**') chan.add_user(usr) self.assertEqual(usr.nick, chan.host_map[usr.host]) self.assertEqual(usr.host, chan.nick_map[usr.nick]) self.assertEqual(usr.nick, chan.find_nick_from_host(usr.host)) self.assertEqual(False, chan.find_nick_from_host('asdsaff')) self.assertEqual(usr.host, chan.find_host_from_nick(usr.nick)) self.assertEqual(False, chan.find_host_from_nick('asdsaff'))
def test_update_nick(self): chan = Channel('#foobar') usr = User('oldnick', '*****@*****.**') chan.add_user(usr) self.assertEqual(usr.nick, chan.find_nick_from_host(usr.host)) self.assertEqual(usr.host, chan.find_host_from_nick('oldnick')) chan.update_nick('oldnick', 'newnick') self.assertEqual(False, chan.find_host_from_nick('oldnick')) self.assertEqual('newnick', chan.find_nick_from_host(usr.host)) self.assertEqual(usr.host, chan.find_host_from_nick('newnick'))
def test_remove_user(self): chan = Channel('#foobar') usr = User('nick', '*****@*****.**') chan.add_user(usr) self.assertEqual(usr.nick, chan.find_nick_from_host(usr.host)) chan.remove_user(host=usr.host) self.assertEqual(False, chan.find_nick_from_host(usr.host)) chan.add_user(usr) self.assertEqual(usr.nick, chan.find_nick_from_host(usr.host)) chan.remove_user(nick=usr.nick) self.assertEqual(False, chan.find_nick_from_host(usr.host))
def test_init(self): chan = Channel('#foobar') self.assertEqual('#foobar', chan.channel) chan = Channel('foobar') self.assertEqual('#foobar', chan.channel)
def test_add_channel(self): srv = Server('irc.host.com:6667') chan = Channel('#foobar') srv.add_channel(chan) self.assertEqual(srv.channels['#foobar'], chan)