def test_issue66(self): chan = irc.Channel('#foobar') user1 = irc.User('nick', 'host.com', 'ident') chan.add_user(user1) user2 = irc.User('nick_', 'host.com', 'ident') chan.add_user(user2) chan.remove_user(name=user1.nick, identifier=user1.host) user2.name = 'nick' chan.remove_user(name=user2.nick, identifier=user2.host)
def test_issue66(self): chan = irc.Channel("#foobar") user1 = irc.User("nick", "host.com", "ident") chan.add_user(user1) user2 = irc.User("nick_", "host.com", "ident") chan.add_user(user2) chan.remove_user(name=user1.nick, identifier=user1.host) user2.name = "nick" chan.remove_user(name=user2.nick, identifier=user2.host)
def test_only_returns_online_admins(self): bot = self.make_bot() bot.admins = ['admin1.com'] chan = make_channel('#chan') bot.add_channel(chan) self.assertEqual(set(), bot.get_admin_nicks()) chan.add_user(irc.User('admin1', 'admin1.com')) self.assertEqual({'admin1'}, bot.get_admin_nicks())
def test_add_user(self): chan = irc.Channel("#foobar") user = irc.User("nick", "host.com", "ident") chan.add_user(user) self.assertEqual(user.nick, chan.find_nick_from_host(user.host)) self.assertEqual(None, chan.find_nick_from_host("asdsaff")) self.assertEqual(user.host, chan.find_host_from_nick(user.nick)) self.assertEqual(None, chan.find_host_from_nick("asdsaff"))
def test_add_user(self): chan = irc.Channel('#foobar') user = irc.User('nick', 'host.com', 'ident') chan.add_user(user) self.assertEqual(user.nick, chan.find_nick_from_host(user.host)) self.assertEqual(None, chan.find_nick_from_host('asdsaff')) self.assertEqual(user.host, chan.find_host_from_nick(user.nick)) self.assertEqual(None, chan.find_host_from_nick('asdsaff'))
def test_only_returns_online_admins(self): bot = self.make_bot() bot.admins = ["admin1.com"] chan = make_channel("#chan") bot.add_channel(chan) self.assertEqual(set(), bot.get_admin_nicks()) chan.add_user(irc.User("admin1", "admin1.com")) self.assertEqual({"admin1"}, bot.get_admin_nicks())
def test_update_nick(self): chan = irc.Channel("#foobar") user = irc.User("oldnick", "host.com", "ident") chan.add_user(user) self.assertEqual(user.nick, chan.find_nick_from_host(user.host)) self.assertEqual(user.host, chan.find_host_from_nick("oldnick")) user.name = "newnick" self.assertEqual(None, chan.find_host_from_nick("oldnick")) self.assertEqual("newnick", chan.find_nick_from_host(user.host)) self.assertEqual(user.host, chan.find_host_from_nick("newnick"))
def test_update_nick(self): chan = irc.Channel('#foobar') user = irc.User('oldnick', 'host.com', 'ident') chan.add_user(user) self.assertEqual(user.nick, chan.find_nick_from_host(user.host)) self.assertEqual(user.host, chan.find_host_from_nick('oldnick')) user.name = 'newnick' self.assertEqual(None, chan.find_host_from_nick('oldnick')) self.assertEqual('newnick', chan.find_nick_from_host(user.host)) self.assertEqual(user.host, chan.find_host_from_nick('newnick'))
def test_remove_user(self): chan = irc.Channel("#foobar") user = irc.User("nick", "host.com", "ident") chan.add_user(user) self.assertEqual(user.nick, chan.find_nick_from_host(user.host)) chan.remove_user(identifier=user.host) self.assertEqual(None, chan.find_nick_from_host(user.host)) chan.add_user(user) self.assertEqual(user.nick, chan.find_nick_from_host(user.host)) chan.remove_user(name=user.nick) self.assertEqual(None, chan.find_nick_from_host(user.host))
def test_remove_user(self): chan = irc.Channel('#foobar') user = irc.User('nick', 'host.com', 'ident') chan.add_user(user) self.assertEqual(user.nick, chan.find_nick_from_host(user.host)) chan.remove_user(identifier=user.host) self.assertEqual(None, chan.find_nick_from_host(user.host)) chan.add_user(user) self.assertEqual(user.nick, chan.find_nick_from_host(user.host)) chan.remove_user(name=user.nick) self.assertEqual(None, chan.find_nick_from_host(user.host))
def test_strips_tilde(self): user = irc.User("foo_bar", "bar.baz", "~foo") self.assertEqual("foo_bar", user.nick) self.assertEqual("bar.baz", user.host) self.assertEqual("foo", user.ident)
def _create_user(self, nick, host=None, is_admin=False): user = irc.User(nick, host=host) user.is_admin = is_admin return user
def test_strips_tilde(self): user = irc.User('foo_bar', 'bar.baz', '~foo') self.assertEqual('foo_bar', user.nick) self.assertEqual('bar.baz', user.host) self.assertEqual('foo', user.ident)