Skip to content

Commit

Permalink
Make AWAY and away-notify tests stricter
Browse files Browse the repository at this point in the history
  • Loading branch information
progval committed Sep 3, 2023
1 parent c58167b commit 44e828a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
18 changes: 13 additions & 5 deletions irctest/server_tests/away.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
RPL_USERHOST,
RPL_WHOISUSER,
)
from irctest.patma import StrRe
from irctest.patma import ANYSTR, StrRe


class AwayTestCase(cases.BaseServerTestCase):
@cases.mark_specifications("RFC2812", "Modern")
def testAway(self):
self.connectClient("bar")
self.getMessages(1)
self.sendLine(1, "AWAY :I'm not here right now")
replies = self.getMessages(1)
self.assertIn(RPL_NOWAWAY, [msg.command for msg in replies])
Expand All @@ -29,6 +30,7 @@ def testAway(self):
command=RPL_AWAY,
params=["qux", "bar", "I'm not here right now"],
)
self.getMessages(1)

self.sendLine(1, "AWAY")
replies = self.getMessages(1)
Expand All @@ -47,12 +49,18 @@ def testAwayAck(self):
"""
self.connectClient("bar")
self.sendLine(1, "AWAY :I'm not here right now")
replies = self.getMessages(1)
self.assertIn(RPL_NOWAWAY, [msg.command for msg in replies])
self.assertMessageMatch(
self.getMessage(1),
command=RPL_NOWAWAY,
params=["bar", ANYSTR])
self.assertEqual(self.getMessages(1), [])

self.sendLine(1, "AWAY")
replies = self.getMessages(1)
self.assertIn(RPL_UNAWAY, [msg.command for msg in replies])
self.assertMessageMatch(
self.getMessage(1),
command=RPL_UNAWAY,
params=["bar", ANYSTR])
self.assertEqual(self.getMessages(1), [])

@cases.mark_specifications("Modern")
def testAwayPrivmsg(self):
Expand Down
27 changes: 21 additions & 6 deletions irctest/server_tests/away_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"""

from irctest import cases
from irctest.patma import ANYSTR, StrRe
from irctest.numerics import (
RPL_NOWAWAY,
RPL_UNAWAY,
)


class AwayNotifyTestCase(cases.BaseServerTestCase):
Expand All @@ -20,14 +25,24 @@ def testAwayNotify(self):
self.getMessages(1)

self.sendLine(2, "AWAY :i'm going away")
self.getMessages(2)
self.assertMessageMatch(
self.getMessage(2),
command=RPL_NOWAWAY,
params=["bar", ANYSTR])
self.assertEqual(self.getMessages(2), [])

awayNotify = self.getMessage(1)
self.assertMessageMatch(awayNotify, command="AWAY", params=["i'm going away"])
self.assertTrue(
awayNotify.prefix.startswith("bar!"),
"Unexpected away-notify source: %s" % (awayNotify.prefix,),
)
self.assertMessageMatch(awayNotify, prefix=StrRe("bar!.*"), command="AWAY", params=["i'm going away"])

self.sendLine(2, "AWAY")
self.assertMessageMatch(
self.getMessage(2),
command=RPL_UNAWAY,
params=["bar", ANYSTR])
self.assertEqual(self.getMessages(2), [])

awayNotify = self.getMessage(1)
self.assertMessageMatch(awayNotify, prefix=StrRe("bar!.*"), command="AWAY", params=[])

@cases.mark_capabilities("away-notify")
def testAwayNotifyOnJoin(self):
Expand Down

0 comments on commit 44e828a

Please sign in to comment.