From 397509a282740ae2042c3cfaf3fe57e74aae65c7 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 10 Apr 2022 14:52:04 +0200 Subject: [PATCH] Move CAP tests to the right module --- irctest/server_tests/cap.py | 57 +++++++++++++++++++ .../server_tests/connection_registration.py | 57 ------------------- 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/irctest/server_tests/cap.py b/irctest/server_tests/cap.py index 1fd5a76..fac6e68 100644 --- a/irctest/server_tests/cap.py +++ b/irctest/server_tests/cap.py @@ -177,3 +177,60 @@ class CapTestCase(cases.BaseServerTestCase, cases.OptionalityHelper): enabled_caps.discard("cap-notify") # implicitly added by some impls self.assertEqual(enabled_caps, {cap1}) self.assertNotIn("time", cap_list.tags) + + @cases.mark_specifications("IRCv3") + def testIrc301CapLs(self): + """ + Current version: + + "The LS subcommand is used to list the capabilities supported by the server. + The client should send an LS subcommand with no other arguments to solicit + a list of all capabilities." + + "If a client has not indicated support for CAP LS 302 features, + the server MUST NOT send these new features to the client." + -- + + Before the v3.1 / v3.2 merge: + + IRCv3.1: “The LS subcommand is used to list the capabilities + supported by the server. The client should send an LS subcommand with + no other arguments to solicit a list of all capabilities.” + -- + + IRCv3.2: “Servers MUST NOT send messages described by this document if + the client only supports version 3.1.” + -- + """ # noqa + self.addClient() + self.sendLine(1, "CAP LS") + m = self.getRegistrationMessage(1) + self.assertNotEqual( + m.params[2], + "*", + m, + fail_msg="Server replied with multi-line CAP LS to a " + "“CAP LS” (ie. IRCv3.1) request: {msg}", + ) + self.assertFalse( + any("=" in cap for cap in m.params[2].split()), + "Server replied with a name-value capability in " + "CAP LS reply as a response to “CAP LS” (ie. IRCv3.1) " + "request: {}".format(m), + ) + + @cases.mark_specifications("IRCv3") + def testEmptyCapList(self): + """“If no capabilities are active, an empty parameter must be sent.” + -- + """ # noqa + self.addClient() + self.sendLine(1, "CAP LIST") + m = self.getRegistrationMessage(1) + self.assertMessageMatch( + m, + command="CAP", + params=["*", "LIST", ""], + fail_msg="Sending “CAP LIST” as first message got a reply " + "that is not “CAP * LIST :”: {msg}", + ) diff --git a/irctest/server_tests/connection_registration.py b/irctest/server_tests/connection_registration.py index 7bf6ffe..e4a1c0b 100644 --- a/irctest/server_tests/connection_registration.py +++ b/irctest/server_tests/connection_registration.py @@ -185,60 +185,3 @@ class ConnectionRegistrationTestCase(cases.BaseServerTestCase): command=ERR_NEEDMOREPARAMS, params=[StrRe(r"(\*|foo)"), "USER", ANYSTR], ) - - @cases.mark_specifications("IRCv3") - def testIrc301CapLs(self): - """ - Current version: - - "The LS subcommand is used to list the capabilities supported by the server. - The client should send an LS subcommand with no other arguments to solicit - a list of all capabilities." - - "If a client has not indicated support for CAP LS 302 features, - the server MUST NOT send these new features to the client." - -- - - Before the v3.1 / v3.2 merge: - - IRCv3.1: “The LS subcommand is used to list the capabilities - supported by the server. The client should send an LS subcommand with - no other arguments to solicit a list of all capabilities.” - -- - - IRCv3.2: “Servers MUST NOT send messages described by this document if - the client only supports version 3.1.” - -- - """ # noqa - self.addClient() - self.sendLine(1, "CAP LS") - m = self.getRegistrationMessage(1) - self.assertNotEqual( - m.params[2], - "*", - m, - fail_msg="Server replied with multi-line CAP LS to a " - "“CAP LS” (ie. IRCv3.1) request: {msg}", - ) - self.assertFalse( - any("=" in cap for cap in m.params[2].split()), - "Server replied with a name-value capability in " - "CAP LS reply as a response to “CAP LS” (ie. IRCv3.1) " - "request: {}".format(m), - ) - - @cases.mark_specifications("IRCv3") - def testEmptyCapList(self): - """“If no capabilities are active, an empty parameter must be sent.” - -- - """ # noqa - self.addClient() - self.sendLine(1, "CAP LIST") - m = self.getRegistrationMessage(1) - self.assertMessageMatch( - m, - command="CAP", - params=["*", "LIST", ""], - fail_msg="Sending “CAP LIST” as first message got a reply " - "that is not “CAP * LIST :”: {msg}", - )