From 7ac4d7f80f4c7e32af867232ba9d6ec4c41c831f Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 27 Jun 2021 09:37:22 +0200 Subject: [PATCH] Use `getRegistrationMessage()` when relevant It's an alias for `filter_pred=lambda m: m.command != "NOTICE", synchronize=False` --- irctest/server_tests/test_account_tag.py | 8 ++------ irctest/server_tests/test_extended_join.py | 4 ++-- irctest/server_tests/test_regressions.py | 5 ++--- irctest/server_tests/test_sasl.py | 8 ++++---- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/irctest/server_tests/test_account_tag.py b/irctest/server_tests/test_account_tag.py index 0e28d84..bd3fa9c 100644 --- a/irctest/server_tests/test_account_tag.py +++ b/irctest/server_tests/test_account_tag.py @@ -18,9 +18,7 @@ class AccountTagTestCase(cases.BaseServerTestCase, cases.OptionalityHelper): self.getRegistrationMessage(2) self.sendLine(2, "AUTHENTICATE PLAIN") - m = self.getMessage( - 2, filter_pred=lambda m: m.command != "NOTICE", synchronize=False - ) + m = self.getRegistrationMessage(2) self.assertMessageMatch( m, command="AUTHENTICATE", @@ -29,9 +27,7 @@ class AccountTagTestCase(cases.BaseServerTestCase, cases.OptionalityHelper): "replied with “AUTHENTICATE +”, but instead sent: {msg}", ) self.sendLine(2, "AUTHENTICATE amlsbGVzAGppbGxlcwBzZXNhbWU=") - m = self.getMessage( - 2, filter_pred=lambda m: m.command != "NOTICE", synchronize=False - ) + m = self.getRegistrationMessage(2) self.assertMessageMatch( m, command="900", diff --git a/irctest/server_tests/test_extended_join.py b/irctest/server_tests/test_extended_join.py index 6c01ed3..205af03 100644 --- a/irctest/server_tests/test_extended_join.py +++ b/irctest/server_tests/test_extended_join.py @@ -12,7 +12,7 @@ class MetadataTestCase(cases.BaseServerTestCase, cases.OptionalityHelper): capabilities = self.getCapLs(2) assert "sasl" in capabilities self.sendLine(2, "AUTHENTICATE PLAIN") - m = self.getMessage(2, filter_pred=lambda m: m.command != "NOTICE") + m = self.getRegistrationMessage(2) self.assertMessageMatch( m, command="AUTHENTICATE", @@ -21,7 +21,7 @@ class MetadataTestCase(cases.BaseServerTestCase, cases.OptionalityHelper): "replied with “AUTHENTICATE +”, but instead sent: {msg}", ) self.sendLine(2, "AUTHENTICATE amlsbGVzAGppbGxlcwBzZXNhbWU=") - m = self.getMessage(2, filter_pred=lambda m: m.command != "NOTICE") + m = self.getRegistrationMessage(2) self.assertMessageMatch( m, command="900", diff --git a/irctest/server_tests/test_regressions.py b/irctest/server_tests/test_regressions.py index 318e86f..96d16c7 100644 --- a/irctest/server_tests/test_regressions.py +++ b/irctest/server_tests/test_regressions.py @@ -137,9 +137,8 @@ class RegressionsTestCase(cases.BaseServerTestCase): self.addClient(2) self.sendLine(2, "NICK alice") self.sendLine(2, "USER u s e r") - replies = set(msg.command for msg in self.getMessages(2)) - self.assertNotIn(ERR_NICKNAMEINUSE, replies) - self.assertIn(RPL_WELCOME, replies) + m = self.getRegistrationMessage(2) + self.assertMessageMatch(m, command=RPL_WELCOME) @cases.mark_specifications("RFC1459") def testNickReleaseQuit(self): diff --git a/irctest/server_tests/test_sasl.py b/irctest/server_tests/test_sasl.py index a230c0e..d4e9a60 100644 --- a/irctest/server_tests/test_sasl.py +++ b/irctest/server_tests/test_sasl.py @@ -32,7 +32,7 @@ class SaslTestCase(cases.BaseServerTestCase, cases.OptionalityHelper): fail_msg="Does not have PLAIN mechanism as the controller " "claims", ) self.sendLine(1, "AUTHENTICATE PLAIN") - m = self.getMessage(1, filter_pred=lambda m: m.command != "NOTICE") + m = self.getRegistrationMessage(1) self.assertMessageMatch( m, command="AUTHENTICATE", @@ -41,7 +41,7 @@ class SaslTestCase(cases.BaseServerTestCase, cases.OptionalityHelper): "replied with “AUTHENTICATE +”, but instead sent: {msg}", ) self.sendLine(1, "AUTHENTICATE amlsbGVzAGppbGxlcwBzZXNhbWU=") - m = self.getMessage(1, filter_pred=lambda m: m.command != "NOTICE") + m = self.getRegistrationMessage(1) self.assertMessageMatch( m, command="900", @@ -91,7 +91,7 @@ class SaslTestCase(cases.BaseServerTestCase, cases.OptionalityHelper): fail_msg="Does not have PLAIN mechanism as the controller " "claims", ) self.sendLine(1, "AUTHENTICATE PLAIN") - m = self.getMessage(1, filter_pred=lambda m: m.command != "NOTICE") + m = self.getRegistrationMessage(1) self.assertMessageMatch( m, command="AUTHENTICATE", @@ -100,7 +100,7 @@ class SaslTestCase(cases.BaseServerTestCase, cases.OptionalityHelper): "replied with “AUTHENTICATE +”, but instead sent: {msg}", ) self.sendLine(1, "AUTHENTICATE AGppbGxlcwBzZXNhbWU=") - m = self.getMessage(1, filter_pred=lambda m: m.command != "NOTICE") + m = self.getRegistrationMessage(1) self.assertMessageMatch( m, command="900",