Skip to content

Commit

Permalink
list: Add test for two channels and/or two params
Browse files Browse the repository at this point in the history
  • Loading branch information
progval committed Apr 8, 2023
1 parent 136a792 commit b2e8f5d
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
106 changes: 106 additions & 0 deletions irctest/server_tests/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: [<channel>{,<channel>}] [<elistcond>{,<elistcond>}]"
-- 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: [<channel>{,<channel>}] [<elistcond>{,<elistcond>}]"
-- 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: [<channel>{,<channel>}] [<elistcond>{,<elistcond>}]"
-- 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
Expand Down
1 change: 1 addition & 0 deletions irctest/specifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ markers =
sts

# isupport tokens
ACCOUNTEXTBAN
BOT
ELIST
INVEX
Expand Down

0 comments on commit b2e8f5d

Please sign in to comment.