2022-04-10 12:51:14 +00:00
|
|
|
"""
|
|
|
|
`Draft IRCv3 channel-rename <https://ircv3.net/specs/extensions/channel-rename>`_
|
|
|
|
"""
|
|
|
|
|
2020-12-14 10:43:06 +00:00
|
|
|
from irctest import cases
|
|
|
|
from irctest.numerics import ERR_CHANOPRIVSNEEDED
|
|
|
|
|
2021-02-22 18:02:13 +00:00
|
|
|
RENAME_CAP = "draft/channel-rename"
|
|
|
|
|
2020-12-14 10:43:06 +00:00
|
|
|
|
2022-04-10 13:07:15 +00:00
|
|
|
@cases.mark_specifications("IRCv3")
|
2021-09-10 05:03:41 +00:00
|
|
|
class ChannelRenameTestCase(cases.BaseServerTestCase):
|
2020-12-14 10:43:06 +00:00
|
|
|
"""Basic tests for channel-rename."""
|
|
|
|
|
|
|
|
def testChannelRename(self):
|
2022-04-10 12:52:31 +00:00
|
|
|
self.connectClient(
|
|
|
|
"bar", name="bar", capabilities=[RENAME_CAP], skip_if_cap_nak=True
|
|
|
|
)
|
|
|
|
self.connectClient("baz", name="baz")
|
2021-02-22 18:02:13 +00:00
|
|
|
self.joinChannel("bar", "#bar")
|
|
|
|
self.joinChannel("baz", "#bar")
|
|
|
|
self.getMessages("bar")
|
|
|
|
self.getMessages("baz")
|
2020-12-14 10:43:06 +00:00
|
|
|
|
2021-02-22 18:02:13 +00:00
|
|
|
self.sendLine("bar", "RENAME #bar #qux :no reason")
|
2021-02-28 17:52:14 +00:00
|
|
|
self.assertMessageMatch(
|
2021-02-22 18:02:13 +00:00
|
|
|
self.getMessage("bar"),
|
|
|
|
command="RENAME",
|
|
|
|
params=["#bar", "#qux", "no reason"],
|
|
|
|
)
|
|
|
|
legacy_responses = self.getMessages("baz")
|
|
|
|
self.assertEqual(
|
|
|
|
1,
|
|
|
|
len(
|
|
|
|
[
|
|
|
|
msg
|
|
|
|
for msg in legacy_responses
|
|
|
|
if msg.command == "PART" and msg.params[0] == "#bar"
|
|
|
|
]
|
|
|
|
),
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
1,
|
|
|
|
len(
|
|
|
|
[
|
|
|
|
msg
|
|
|
|
for msg in legacy_responses
|
|
|
|
if msg.command == "JOIN" and msg.params == ["#qux"]
|
|
|
|
]
|
|
|
|
),
|
|
|
|
)
|
2020-12-14 10:43:06 +00:00
|
|
|
|
2021-02-22 18:02:13 +00:00
|
|
|
self.joinChannel("baz", "#bar")
|
|
|
|
self.sendLine("baz", "MODE #bar +k beer")
|
|
|
|
self.assertNotIn(
|
|
|
|
ERR_CHANOPRIVSNEEDED, [msg.command for msg in self.getMessages("baz")]
|
|
|
|
)
|