mirror of
https://github.com/progval/irctest.git
synced 2025-04-06 23:39:46 +00:00
Make tests around joining channels more deterministic
This commit is contained in:
@ -373,6 +373,17 @@ class BaseServerTestCase(_IrcTestCase):
|
|||||||
'received responses: {list}',
|
'received responses: {list}',
|
||||||
extra_format=(channel,))
|
extra_format=(channel,))
|
||||||
|
|
||||||
|
def joinChannel(self, client, channel):
|
||||||
|
self.sendLine(client, 'JOIN {}'.format(channel))
|
||||||
|
# wait until we see them join the channel
|
||||||
|
joined = False
|
||||||
|
while not joined:
|
||||||
|
for msg in self.getMessages(1):
|
||||||
|
# todo: also respond to cannot join channel numeric
|
||||||
|
if msg.command.upper() == 'JOIN' and 0 < len(msg.params) and msg.params[0].lower() == channel.lower():
|
||||||
|
joined = True
|
||||||
|
break
|
||||||
|
|
||||||
class OptionalityHelper:
|
class OptionalityHelper:
|
||||||
def checkSaslSupport(self):
|
def checkSaslSupport(self):
|
||||||
if self.controller.supported_sasl_mechanisms:
|
if self.controller.supported_sasl_mechanisms:
|
||||||
|
@ -148,14 +148,17 @@ class JoinTestCase(cases.BaseServerTestCase):
|
|||||||
and <https://tools.ietf.org/html/rfc2812#section-3.2.1>
|
and <https://tools.ietf.org/html/rfc2812#section-3.2.1>
|
||||||
"""
|
"""
|
||||||
self.connectClient('foo')
|
self.connectClient('foo')
|
||||||
|
self.joinChannel(1, '#chan')
|
||||||
|
|
||||||
self.connectClient('bar')
|
self.connectClient('bar')
|
||||||
self.sendLine(1, 'JOIN #chan')
|
self.joinChannel(2, '#chan')
|
||||||
self.sendLine(2, 'JOIN #chan')
|
|
||||||
# TODO: check foo is opped OR +t is unset
|
|
||||||
|
|
||||||
self.getMessages(1)
|
self.getMessages(1)
|
||||||
self.getMessages(2)
|
self.getMessages(2)
|
||||||
self.getMessages(1)
|
self.getMessages(1)
|
||||||
|
self.getMessages(2)
|
||||||
|
|
||||||
|
# TODO: check foo is opped OR +t is unset
|
||||||
|
|
||||||
self.sendLine(1, 'TOPIC #chan :T0P1C')
|
self.sendLine(1, 'TOPIC #chan :T0P1C')
|
||||||
try:
|
try:
|
||||||
@ -181,14 +184,15 @@ class JoinTestCase(cases.BaseServerTestCase):
|
|||||||
and <https://tools.ietf.org/html/rfc2812#section-3.2.1>
|
and <https://tools.ietf.org/html/rfc2812#section-3.2.1>
|
||||||
"""
|
"""
|
||||||
self.connectClient('foo')
|
self.connectClient('foo')
|
||||||
|
self.joinChannel(1, '#chan')
|
||||||
|
|
||||||
self.connectClient('bar')
|
self.connectClient('bar')
|
||||||
self.sendLine(1, 'JOIN #chan')
|
self.joinChannel(2, '#chan')
|
||||||
self.sendLine(2, 'JOIN #chan')
|
|
||||||
# TODO: check foo is opped
|
|
||||||
|
|
||||||
self.getMessages(1)
|
self.getMessages(1)
|
||||||
self.getMessages(2)
|
self.getMessages(2)
|
||||||
self.getMessages(1)
|
|
||||||
|
# TODO: check foo is opped
|
||||||
|
|
||||||
self.sendLine(1, 'MODE #chan +t')
|
self.sendLine(1, 'MODE #chan +t')
|
||||||
try:
|
try:
|
||||||
@ -282,12 +286,15 @@ class JoinTestCase(cases.BaseServerTestCase):
|
|||||||
and <https://tools.ietf.org/html/rfc2812#section-3.2.1>
|
and <https://tools.ietf.org/html/rfc2812#section-3.2.1>
|
||||||
"""
|
"""
|
||||||
self.connectClient('foo')
|
self.connectClient('foo')
|
||||||
|
self.joinChannel(1, '#chan')
|
||||||
|
|
||||||
self.connectClient('bar')
|
self.connectClient('bar')
|
||||||
|
self.joinChannel(2, '#chan')
|
||||||
|
|
||||||
self.connectClient('baz')
|
self.connectClient('baz')
|
||||||
self.sendLine(1, 'JOIN #chan')
|
self.joinChannel(3, '#chan')
|
||||||
|
|
||||||
# TODO: check foo is an operator
|
# TODO: check foo is an operator
|
||||||
self.sendLine(2, 'JOIN #chan')
|
|
||||||
self.sendLine(3, 'JOIN #chan')
|
|
||||||
|
|
||||||
import time
|
import time
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
@ -319,24 +326,28 @@ class JoinTestCase(cases.BaseServerTestCase):
|
|||||||
-- https://tools.ietf.org/html/rfc2812#section-3.2.8
|
-- https://tools.ietf.org/html/rfc2812#section-3.2.8
|
||||||
"""
|
"""
|
||||||
self.connectClient('foo')
|
self.connectClient('foo')
|
||||||
|
self.joinChannel(1, '#chan')
|
||||||
|
|
||||||
self.connectClient('bar')
|
self.connectClient('bar')
|
||||||
|
self.joinChannel(2, '#chan')
|
||||||
|
|
||||||
self.connectClient('baz')
|
self.connectClient('baz')
|
||||||
|
self.joinChannel(3, '#chan')
|
||||||
|
|
||||||
self.connectClient('qux')
|
self.connectClient('qux')
|
||||||
|
<<<<<<< HEAD
|
||||||
self.sendLine(1, 'JOIN #chan')
|
self.sendLine(1, 'JOIN #chan')
|
||||||
|
=======
|
||||||
|
self.joinChannel(4, '#chan')
|
||||||
|
|
||||||
|
>>>>>>> e4c3490... Make tests around joining channels more deterministic
|
||||||
# TODO: check foo is an operator
|
# TODO: check foo is an operator
|
||||||
self.sendLine(2, 'JOIN #chan')
|
|
||||||
self.sendLine(3, 'JOIN #chan')
|
|
||||||
self.sendLine(4, 'JOIN #chan')
|
|
||||||
|
|
||||||
# Synchronize
|
# Synchronize
|
||||||
self.getMessages(1)
|
self.getMessages(1)
|
||||||
self.getMessages(2)
|
self.getMessages(2)
|
||||||
self.getMessages(3)
|
self.getMessages(3)
|
||||||
self.getMessages(4)
|
self.getMessages(4)
|
||||||
self.getMessages(1)
|
|
||||||
self.getMessages(2)
|
|
||||||
self.getMessages(3)
|
|
||||||
self.getMessages(4)
|
|
||||||
|
|
||||||
self.sendLine(1, 'KICK #chan,#chan bar,baz :bye')
|
self.sendLine(1, 'KICK #chan,#chan bar,baz :bye')
|
||||||
try:
|
try:
|
||||||
|
@ -44,8 +44,7 @@ class MetadataTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
|||||||
def testNotLoggedIn(self):
|
def testNotLoggedIn(self):
|
||||||
self.connectClient('foo', capabilities=['extended-join'],
|
self.connectClient('foo', capabilities=['extended-join'],
|
||||||
skip_if_cap_nak=True)
|
skip_if_cap_nak=True)
|
||||||
self.sendLine(1, 'JOIN #chan')
|
self.joinChannel(1, '#chan')
|
||||||
self.getMessages(1)
|
|
||||||
|
|
||||||
self.controller.registerUser(self, 'jilles', 'sesame')
|
self.controller.registerUser(self, 'jilles', 'sesame')
|
||||||
self.connectRegisteredClient('bar')
|
self.connectRegisteredClient('bar')
|
||||||
|
Reference in New Issue
Block a user