test cap removal with, e.g., CAP REQ :-server-time

This commit is contained in:
Shivaram Lingamneni 2019-02-13 19:32:57 -05:00
parent a3ad8a1038
commit dc3ac21f75

View File

@ -95,3 +95,33 @@ class CapTestCase(cases.BaseServerTestCase):
subcommand='ACK', subparams=['multi-prefix'], subcommand='ACK', subparams=['multi-prefix'],
fail_msg='Expected “CAP ACK :multi-prefix” after ' fail_msg='Expected “CAP ACK :multi-prefix” after '
'sending “CAP REQ :multi-prefix”, but got {msg}.') 'sending “CAP REQ :multi-prefix”, but got {msg}.')
@cases.SpecificationSelector.requiredBySpecification('Oragono')
def testCapRemovalByClient(self):
"""Test CAP LIST and removal of caps via CAP REQ :-tagname."""
self.addClient(1)
self.sendLine(1, 'CAP LS 302')
self.assertIn('multi-prefix', self.getCapLs(1))
self.sendLine(1, 'CAP REQ :echo-message server-time')
self.sendLine(1, 'nick bar')
self.sendLine(1, 'user user 0 * realname')
self.sendLine(1, 'CAP END')
self.skipToWelcome(1)
self.getMessages(1)
self.sendLine(1, 'CAP LIST')
messages = self.getMessages(1)
cap_list = [m for m in messages if m.command == 'CAP'][0]
self.assertEqual(set(cap_list.params[2].split()), {'echo-message', 'server-time'})
self.assertIn('time', cap_list.tags)
# remove the server-time cap
self.sendLine(1, 'CAP REQ :-server-time')
self.getMessages(1)
# server-time should be disabled
self.sendLine(1, 'CAP LIST')
messages = self.getMessages(1)
cap_list = [m for m in messages if m.command == 'CAP'][0]
self.assertEqual(set(cap_list.params[2].split()), {'echo-message'})
self.assertNotIn('time', cap_list.tags)