3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 04:02:45 +01:00

test kick/nickClient; make kickClient update channel userlist...

This commit is contained in:
James Lu 2015-07-03 23:48:28 -07:00
parent 18528c9cab
commit 942f97352d
2 changed files with 16 additions and 0 deletions

View File

@ -106,6 +106,10 @@ def kickClient(irc, numeric, channel, target, reason=None):
if not reason:
reason = 'No reason given'
_sendFromUser(irc, numeric, 'KICK %s %s :%s' % (channel, target, reason))
# We can pretend the target left by its own will; all we really care about
# is that the target gets removed from the channel userlist, and calling
# handle_part() does that just fine.
handle_part(irc, target, 'KICK', [channel])
def nickClient(irc, numeric, newnick):
"""<irc object> <client numeric> <new nickname>

View File

@ -71,5 +71,17 @@ class TestInspIRCdProtocol(unittest.TestCase):
self.assertNotIn(u, self.irc.servers[self.irc.sid].users)
pass
def testKickClient(self):
target = self.proto.spawnClient(self.irc, 'soccerball', 'soccerball', 'abcd').uid
self.proto.joinClient(self.irc, target, '#pylink')
self.assertIn(self.u, self.irc.channels['#pylink'].users)
self.assertIn(target, self.irc.channels['#pylink'].users)
self.proto.kickClient(self.irc, self.u, '#pylink', target, 'Pow!')
self.assertNotIn(target, self.irc.channels['#pylink'].users)
def testNickClient(self):
self.proto.nickClient(self.irc, self.u, 'NotPyLink')
self.assertEqual('NotPyLink', self.irc.users[self.u].nick)
if __name__ == '__main__':
unittest.main()