From 39587c3c491525f59221f87a3ca2232ed44381fe Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 4 Sep 2021 21:08:06 +0200 Subject: [PATCH] Add testBanList --- irctest/server_tests/chmodes/ban.py | 51 +++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/irctest/server_tests/chmodes/ban.py b/irctest/server_tests/chmodes/ban.py index 8a0f956..22cdebc 100644 --- a/irctest/server_tests/chmodes/ban.py +++ b/irctest/server_tests/chmodes/ban.py @@ -1,9 +1,10 @@ from irctest import cases -from irctest.numerics import ERR_BANNEDFROMCHAN +from irctest.numerics import ERR_BANNEDFROMCHAN, RPL_BANLIST, RPL_ENDOFBANLIST +from irctest.patma import ANYSTR, StrRe class BanModeTestCase(cases.BaseServerTestCase): - @cases.mark_specifications("RFC1459", "RFC2812") + @cases.mark_specifications("RFC1459", "RFC2812", "Modern") def testBan(self): """Basic ban operation""" self.connectClient("chanop", name="chanop") @@ -23,6 +24,52 @@ class BanModeTestCase(cases.BaseServerTestCase): self.sendLine("bar", "JOIN #chan") self.assertMessageMatch(self.getMessage("bar"), command="JOIN") + @cases.mark_specifications("Modern") + def testBanList(self): + """https://github.com/ircdocs/modern-irc/pull/125""" + self.connectClient("chanop") + self.joinChannel(1, "#chan") + self.getMessages(1) + self.sendLine(1, "MODE #chan +b bar!*@*") + self.assertMessageMatch(self.getMessage(1), command="MODE") + + self.sendLine(1, "MODE #chan +b") + + m = self.getMessage(1) + if len(m.params) == 3: + # Old format + self.assertMessageMatch( + m, + command=RPL_BANLIST, + params=[ + "chanop", + "#chan", + "bar!*@*", + ], + ) + else: + self.assertMessageMatch( + m, + command=RPL_BANLIST, + params=[ + "chanop", + "#chan", + "bar!*@*", + StrRe("chanop(!.*@.*)?"), + StrRe("[0-9]+"), + ], + ) + + self.assertMessageMatch( + self.getMessage(1), + command=RPL_ENDOFBANLIST, + params=[ + "chanop", + "#chan", + ANYSTR, + ], + ) + @cases.mark_specifications("Ergo") def testCaseInsensitive(self): """Some clients allow unsetting modes if their argument matches