From b2e8f5d1e17dd69cd348b26a9de5817fb52fab1c Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 8 Apr 2023 17:37:12 +0200 Subject: [PATCH 1/4] list: Add test for two channels and/or two params --- irctest/server_tests/list.py | 106 +++++++++++++++++++++++++++++++++++ irctest/specifications.py | 1 + pytest.ini | 1 + 3 files changed, 108 insertions(+) diff --git a/irctest/server_tests/list.py b/irctest/server_tests/list.py index 2063acbe..6b8f6824 100644 --- a/irctest/server_tests/list.py +++ b/irctest/server_tests/list.py @@ -238,6 +238,112 @@ def testListUsers(self): self.sendLine(3, "LIST <100") self.assertEqual(self._parseChanList(3), {"#chan1", "#chan2"}) + @cases.mark_specifications("Modern") + def testListTwoChannels(self): + """ + "Parameters: [{,}] [{,}]" + -- https://modern.ircdocs.horse/#list-message + """ + self.connectClient("foo") + + if "U" not in self.server_support.get("ELIST", ""): + raise runner.OptionalExtensionNotSupported("ELIST=U") + + if "TARGMAX" in self.server_support: + for item in (self.server_support["TARGMAX"]).split(","): + (command, max_) = item.split(":", 1) + if command == "LIST" and int(max_ or "1000") < 2: + raise runner.OptionalExtensionNotSupported("TARGMAX=LIST >= 2") + + self.sendLine(1, "JOIN #chan1") + self.getMessages(1) + self.sendLine(1, "JOIN #chan2") + self.getMessages(1) + self.sendLine(1, "JOIN #chan3") + self.getMessages(1) + + self.connectClient("bar") + self.sendLine(2, "JOIN #chan2") + self.getMessages(2) + + self.connectClient("baz") + + self.sendLine(3, "LIST") + self.assertEqual(self._parseChanList(3), {"#chan1", "#chan2", "#chan3"}) + + self.sendLine(3, "LIST #chan1,#chan2") + self.assertEqual(self._parseChanList(3), {"#chan1", "#chan2"}) + + @cases.mark_isupport("ELIST") + @cases.mark_specifications("Modern") + def testListTwoParams(self): + """ + "Parameters: [{,}] [{,}]" + -- https://modern.ircdocs.horse/#list-message + """ + self.connectClient("foo") + + if "U" not in self.server_support.get("ELIST", ""): + raise runner.OptionalExtensionNotSupported("ELIST=U") + + self.sendLine(1, "JOIN #chan1") + self.getMessages(1) + self.sendLine(1, "JOIN #chan2") + self.getMessages(1) + + self.connectClient("bar") + self.sendLine(2, "JOIN #chan2") + self.getMessages(2) + + self.connectClient("baz") + + self.sendLine(3, "LIST #chan1 >0") + self.assertEqual(self._parseChanList(3), {"#chan1"}) + + self.sendLine(3, "LIST #chan1 <1") + self.assertEqual(self._parseChanList(3), set()) + + self.sendLine(3, "LIST #chan1,#chan2 >0") + self.assertEqual(self._parseChanList(3), {"#chan1", "#chan2"}) + + self.sendLine(3, "LIST #chan1,#chan2 <1") + self.assertEqual(self._parseChanList(3), set()) + + @cases.mark_isupport("ELIST") + @cases.mark_specifications("Modern") + def testListTwoParamsTwoChannels(self): + """ + "Parameters: [{,}] [{,}]" + -- https://modern.ircdocs.horse/#list-message + """ + self.connectClient("foo") + + if "U" not in self.server_support.get("ELIST", ""): + raise runner.OptionalExtensionNotSupported("ELIST=U") + + if "TARGMAX" in self.server_support: + for item in (self.server_support["TARGMAX"]).split(","): + (command, max_) = item.split(":", 1) + if command == "LIST" and int(max_ or "1000") < 2: + raise runner.OptionalExtensionNotSupported("TARGMAX=LIST >= 2") + + self.sendLine(1, "JOIN #chan1") + self.getMessages(1) + self.sendLine(1, "JOIN #chan2") + self.getMessages(1) + + self.connectClient("bar") + self.sendLine(2, "JOIN #chan2") + self.getMessages(2) + + self.connectClient("baz") + + self.sendLine(3, "LIST #chan1,#chan2 >0") + self.assertEqual(self._parseChanList(3), {"#chan1", "#chan2"}) + + self.sendLine(3, "LIST #chan1,#chan2 <1") + self.assertEqual(self._parseChanList(3), set()) + class FaketimeListTestCase(_BasedListTestCase): faketime = "+1y x30" # for every wall clock second, 1 minute passed for the server diff --git a/irctest/specifications.py b/irctest/specifications.py index 9c4617bc..cb68a36e 100644 --- a/irctest/specifications.py +++ b/irctest/specifications.py @@ -52,6 +52,7 @@ def from_name(cls, name: str) -> Capabilities: @enum.unique class IsupportTokens(enum.Enum): + ACCOUNTEXTBAN = "ACCOUNTEXTBAN" BOT = "BOT" ELIST = "ELIST" INVEX = "INVEX" diff --git a/pytest.ini b/pytest.ini index 375f2bb3..fe766b55 100644 --- a/pytest.ini +++ b/pytest.ini @@ -34,6 +34,7 @@ markers = sts # isupport tokens + ACCOUNTEXTBAN BOT ELIST INVEX From 199d15b434639d37c93a506d0f2e71ea0a8c6d41 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 8 Apr 2023 18:01:22 +0200 Subject: [PATCH 2/4] testListTwoChannels doesn't need ELIST=U --- irctest/server_tests/list.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/irctest/server_tests/list.py b/irctest/server_tests/list.py index 6b8f6824..ad61abbf 100644 --- a/irctest/server_tests/list.py +++ b/irctest/server_tests/list.py @@ -246,9 +246,6 @@ def testListTwoChannels(self): """ self.connectClient("foo") - if "U" not in self.server_support.get("ELIST", ""): - raise runner.OptionalExtensionNotSupported("ELIST=U") - if "TARGMAX" in self.server_support: for item in (self.server_support["TARGMAX"]).split(","): (command, max_) = item.split(":", 1) From 67f08fb211d67bdb4b3362d7dab1c637325538fd Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 8 Apr 2023 18:22:45 +0200 Subject: [PATCH 3/4] what about two masks? --- irctest/server_tests/list.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/irctest/server_tests/list.py b/irctest/server_tests/list.py index ad61abbf..631932c7 100644 --- a/irctest/server_tests/list.py +++ b/irctest/server_tests/list.py @@ -271,6 +271,38 @@ def testListTwoChannels(self): self.sendLine(3, "LIST #chan1,#chan2") self.assertEqual(self._parseChanList(3), {"#chan1", "#chan2"}) + @cases.mark_isupport("ELIST") + def testListTwoMasks(self): + self.connectClient("foo") + + if "M" not in self.server_support.get("ELIST", ""): + raise runner.OptionalExtensionNotSupported("ELIST=M") + + if "TARGMAX" in self.server_support: + for item in (self.server_support["TARGMAX"]).split(","): + (command, max_) = item.split(":", 1) + if command == "LIST" and int(max_ or "1000") < 2: + raise runner.OptionalExtensionNotSupported("TARGMAX=LIST >= 2") + + self.sendLine(1, "JOIN #chan1") + self.getMessages(1) + self.sendLine(1, "JOIN #chan2") + self.getMessages(1) + self.sendLine(1, "JOIN #chan3") + self.getMessages(1) + + self.connectClient("bar") + self.sendLine(2, "JOIN #chan2") + self.getMessages(2) + + self.connectClient("baz") + + self.sendLine(3, "LIST") + self.assertEqual(self._parseChanList(3), {"#chan1", "#chan2", "#chan3"}) + + self.sendLine(3, "LIST *an1,*an2") + self.assertEqual(self._parseChanList(3), {"#chan1", "#chan2"}) + @cases.mark_isupport("ELIST") @cases.mark_specifications("Modern") def testListTwoParams(self): From 6559bb34c03c937f6a507b8c20d7c97b3605cc73 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 8 Apr 2023 18:59:52 +0200 Subject: [PATCH 4/4] Remove testListTwoParamsTwoChannels's assertions from testListTwoParams --- irctest/server_tests/list.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/irctest/server_tests/list.py b/irctest/server_tests/list.py index 631932c7..4d02cb0d 100644 --- a/irctest/server_tests/list.py +++ b/irctest/server_tests/list.py @@ -332,12 +332,6 @@ def testListTwoParams(self): self.sendLine(3, "LIST #chan1 <1") self.assertEqual(self._parseChanList(3), set()) - self.sendLine(3, "LIST #chan1,#chan2 >0") - self.assertEqual(self._parseChanList(3), {"#chan1", "#chan2"}) - - self.sendLine(3, "LIST #chan1,#chan2 <1") - self.assertEqual(self._parseChanList(3), set()) - @cases.mark_isupport("ELIST") @cases.mark_specifications("Modern") def testListTwoParamsTwoChannels(self):