Add tests for PING and PONG

This commit is contained in:
Valentin Lorentz 2021-08-28 18:03:15 +02:00 committed by Val Lorentz
parent 15d21f4ee4
commit 03a401f911
2 changed files with 43 additions and 1 deletions

View File

@ -16,7 +16,7 @@ OPER_PWD = "frenchfries"
BASE_CONFIG = {
"network": {"name": "ErgoTest"},
"server": {
"name": "ergo.test",
"name": "My.Little.Server",
"listeners": {},
"max-sendq": "16k",
"connection-limits": {

View File

@ -0,0 +1,42 @@
from irctest import cases
from irctest.numerics import ERR_NEEDMOREPARAMS, ERR_NOORIGIN
from irctest.patma import ANYSTR
class PingPongTestCase(cases.BaseServerTestCase):
@cases.mark_specifications("Modern")
def testPing(self):
"""https://github.com/ircdocs/modern-irc/pull/99"""
self.connectClient("foo")
self.sendLine(1, "PING abcdef")
self.assertMessageMatch(
self.getMessage(1), command="PONG", params=["My.Little.Server", "abcdef"]
)
@cases.mark_specifications("Modern")
def testPingNoToken(self):
"""https://github.com/ircdocs/modern-irc/pull/99"""
self.connectClient("foo")
self.sendLine(1, "PING")
m = self.getMessage(1)
if m.command == ERR_NOORIGIN:
self.assertMessageMatch(m, command=ERR_NOORIGIN, params=["foo", ANYSTR])
else:
self.assertMessageMatch(
m, command=ERR_NEEDMOREPARAMS, params=["foo", "PING", ANYSTR]
)
@cases.mark_specifications("Modern")
def testPingEmptyToken(self):
"""https://github.com/ircdocs/modern-irc/pull/99"""
self.connectClient("foo")
self.sendLine(1, "PING :")
m = self.getMessage(1)
if m.command == "PONG":
self.assertMessageMatch(m, command="PONG", params=["My.Little.Server", ""])
elif m.command == ERR_NOORIGIN:
self.assertMessageMatch(m, command=ERR_NOORIGIN, params=["foo", ANYSTR])
else:
self.assertMessageMatch(
m, command=ERR_NEEDMOREPARAMS, params=["foo", "PING", ANYSTR]
)