mirror of
https://github.com/progval/irctest.git
synced 2025-04-05 06:49:47 +00:00
add a test for AWAY :\r\n (#175)
This commit is contained in:
committed by
GitHub
parent
9d4212504b
commit
40385c112b
@ -4,7 +4,13 @@ AWAY command (`RFC 2812 <https://datatracker.ietf.org/doc/html/rfc2812#section-4
|
||||
"""
|
||||
|
||||
from irctest import cases
|
||||
from irctest.numerics import RPL_AWAY, RPL_NOWAWAY, RPL_UNAWAY, RPL_USERHOST
|
||||
from irctest.numerics import (
|
||||
RPL_AWAY,
|
||||
RPL_NOWAWAY,
|
||||
RPL_UNAWAY,
|
||||
RPL_USERHOST,
|
||||
RPL_WHOISUSER,
|
||||
)
|
||||
from irctest.patma import StrRe
|
||||
|
||||
|
||||
@ -139,3 +145,33 @@ class AwayTestCase(cases.BaseServerTestCase):
|
||||
self.assertMessageMatch(
|
||||
self.getMessage(2), command=RPL_USERHOST, params=["qux", StrRe(r"bar=-.*")]
|
||||
)
|
||||
|
||||
@cases.mark_specifications("Modern")
|
||||
def testAwayEmptyMessage(self):
|
||||
"""
|
||||
"If [AWAY] is sent with a nonempty parameter (the 'away message')
|
||||
then the user is set to be away. If this command is sent with no
|
||||
parameters, or with the empty string as the parameter, the user is no
|
||||
longer away."
|
||||
-- https://modern.ircdocs.horse/#away-message
|
||||
"""
|
||||
self.connectClient("bar", name="bar")
|
||||
self.connectClient("qux", name="qux")
|
||||
|
||||
self.sendLine("bar", "AWAY :I'm not here right now")
|
||||
replies = self.getMessages("bar")
|
||||
self.assertIn(RPL_NOWAWAY, [msg.command for msg in replies])
|
||||
self.sendLine("qux", "WHOIS bar")
|
||||
replies = self.getMessages("qux")
|
||||
self.assertIn(RPL_WHOISUSER, [msg.command for msg in replies])
|
||||
self.assertIn(RPL_AWAY, [msg.command for msg in replies])
|
||||
|
||||
# empty final parameter to AWAY is treated the same as no parameter,
|
||||
# i.e., the client is considered to be no longer away
|
||||
self.sendLine("bar", "AWAY :")
|
||||
replies = self.getMessages("bar")
|
||||
self.assertIn(RPL_UNAWAY, [msg.command for msg in replies])
|
||||
self.sendLine("qux", "WHOIS bar")
|
||||
replies = self.getMessages("qux")
|
||||
self.assertIn(RPL_WHOISUSER, [msg.command for msg in replies])
|
||||
self.assertNotIn(RPL_AWAY, [msg.command for msg in replies])
|
||||
|
Reference in New Issue
Block a user