Add support for clients refusing negotiation and fix typos.

This commit is contained in:
Valentin Lorentz
2015-12-19 11:32:19 +01:00
parent f9c497b7ca
commit 2a4b1f1540
2 changed files with 8 additions and 3 deletions

View File

@ -68,6 +68,8 @@ class ClientNegociationHelper:
self.protocol_version = 301
elif m.params == ['LS', '302']:
self.protocol_version = 302
elif m.params == ['END']:
self.protocol_version = None
else:
raise AssertionError('Unknown CAP params: {}'
.format(m.params))
@ -86,7 +88,11 @@ class ClientNegociationHelper:
else:
return True
def negociateCapabilities(self, cap_ls):
def negotiateCapabilities(self, cap_ls):
self.readCapLs()
if not self.protocol_version:
# No negotiation.
return
self.sendLine('CAP * LS :')
while True:
m = self.getMessage(filter_pred=self.userNickPredicate)

View File

@ -6,6 +6,5 @@ class CapTestCase(cases.BaseClientTestCase, cases.ClientNegociationHelper):
self.readCapLs()
def testEmptyCapLs(self):
self.readCapLs()
m = self.negociateCapabilities([])
m = self.negotiateCapabilities([])
self.assertEqual(m, Message([], None, 'CAP', ['END']))