Add tests for NICK collisions.

This commit is contained in:
Valentin Lorentz 2015-12-21 00:25:40 +01:00
parent 5da956f2d9
commit baa7b5306e

View File

@ -47,3 +47,22 @@ class ConnectionRegistrationTestCase(cases.BaseServerTestCase):
m = self.getMessage(1)
self.assertMessageEqual(m, command='ERROR')
self.assertDisconnected(1)
def testNickCollision(self):
self.connectClient('foo')
self.addClient()
self.sendLine(2, 'NICK foo')
self.sendLine(2, 'USER username * * :Realname')
m = self.getMessage(2, filter_pred=lambda m:m.command != 'NOTICE')
self.assertNotEqual(m.command, '001')
def testEarlyNickCollision(self):
self.addClient()
self.addClient()
self.sendLine(1, 'NICK foo')
self.sendLine(2, 'NICK foo')
self.sendLine(1, 'USER username * * :Realname')
self.sendLine(2, 'USER username * * :Realname')
m1 = self.getMessage(1, filter_pred=lambda m:m.command != 'NOTICE')
m2 = self.getMessage(2, filter_pred=lambda m:m.command != 'NOTICE')
self.assertNotEqual((m1.command, m2.command), ('001', '001'))