mirror of https://github.com/progval/irctest.git
testMonitorForbidsMasks: Allow ERR_ERRONEUSNICKNAME reply (#266)
This is returned by Sable
This commit is contained in:
parent
2ae612c68f
commit
e6dfb87759
|
@ -160,6 +160,7 @@ class _IrcTestCase(Generic[TController]):
|
||||||
def messageDiffers(
|
def messageDiffers(
|
||||||
self,
|
self,
|
||||||
msg: Message,
|
msg: Message,
|
||||||
|
command: Union[str, None, patma.Operator] = None,
|
||||||
params: Optional[List[Union[str, None, patma.Operator]]] = None,
|
params: Optional[List[Union[str, None, patma.Operator]]] = None,
|
||||||
target: Optional[str] = None,
|
target: Optional[str] = None,
|
||||||
tags: Optional[
|
tags: Optional[
|
||||||
|
@ -186,6 +187,14 @@ class _IrcTestCase(Generic[TController]):
|
||||||
msg=msg,
|
msg=msg,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if command is not None and not patma.match_string(msg.command, command):
|
||||||
|
fail_msg = (
|
||||||
|
fail_msg or "expected command to match {expects}, got {got}: {msg}"
|
||||||
|
)
|
||||||
|
return fail_msg.format(
|
||||||
|
*extra_format, got=msg.command, expects=command, msg=msg
|
||||||
|
)
|
||||||
|
|
||||||
if prefix is not None and not patma.match_string(msg.prefix, prefix):
|
if prefix is not None and not patma.match_string(msg.prefix, prefix):
|
||||||
fail_msg = (
|
fail_msg = (
|
||||||
fail_msg or "expected prefix to match {expects}, got {got}: {msg}"
|
fail_msg or "expected prefix to match {expects}, got {got}: {msg}"
|
||||||
|
@ -214,7 +223,7 @@ class _IrcTestCase(Generic[TController]):
|
||||||
or "expected nick to be {expects}, got {got} instead: {msg}"
|
or "expected nick to be {expects}, got {got} instead: {msg}"
|
||||||
)
|
)
|
||||||
return fail_msg.format(
|
return fail_msg.format(
|
||||||
*extra_format, got=got_nick, expects=nick, param=key, msg=msg
|
*extra_format, got=got_nick, expects=nick, msg=msg
|
||||||
)
|
)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -173,7 +173,7 @@ MESSAGE_SPECS: List[Tuple[Dict, List[str], List[str], List[str]]] = [
|
||||||
],
|
],
|
||||||
# and they each error with:
|
# and they each error with:
|
||||||
[
|
[
|
||||||
"expected command to be PRIVMSG, got PRIVMG",
|
"expected command to match PRIVMSG, got PRIVMG",
|
||||||
"expected tags to match {'tag1': 'bar', RemainingKeys(ANYSTR): ANYOPTSTR}, got {'tag1': 'value1'}",
|
"expected tags to match {'tag1': 'bar', RemainingKeys(ANYSTR): ANYOPTSTR}, got {'tag1': 'value1'}",
|
||||||
"expected params to match ['#chan', 'hello'], got ['#chan', 'hello2']",
|
"expected params to match ['#chan', 'hello'], got ['#chan', 'hello2']",
|
||||||
"expected params to match ['#chan', 'hello'], got ['#chan2', 'hello']",
|
"expected params to match ['#chan', 'hello'], got ['#chan2', 'hello']",
|
||||||
|
@ -206,7 +206,7 @@ MESSAGE_SPECS: List[Tuple[Dict, List[str], List[str], List[str]]] = [
|
||||||
],
|
],
|
||||||
# and they each error with:
|
# and they each error with:
|
||||||
[
|
[
|
||||||
"expected command to be PRIVMSG, got PRIVMG",
|
"expected command to match PRIVMSG, got PRIVMG",
|
||||||
"expected tags to match {StrRe(r'tag[12]'): 'bar', RemainingKeys(ANYSTR): ANYOPTSTR}, got {'tag1': 'value1'}",
|
"expected tags to match {StrRe(r'tag[12]'): 'bar', RemainingKeys(ANYSTR): ANYOPTSTR}, got {'tag1': 'value1'}",
|
||||||
"expected params to match ['#chan', 'hello'], got ['#chan', 'hello2']",
|
"expected params to match ['#chan', 'hello'], got ['#chan', 'hello2']",
|
||||||
"expected params to match ['#chan', 'hello'], got ['#chan2', 'hello']",
|
"expected params to match ['#chan', 'hello'], got ['#chan2', 'hello']",
|
||||||
|
@ -235,7 +235,7 @@ MESSAGE_SPECS: List[Tuple[Dict, List[str], List[str], List[str]]] = [
|
||||||
],
|
],
|
||||||
# and they each error with:
|
# and they each error with:
|
||||||
[
|
[
|
||||||
"expected command to be PRIVMSG, got PRIVMG",
|
"expected command to match PRIVMSG, got PRIVMG",
|
||||||
"expected tags to match {'tag1': 'bar', RemainingKeys(NotStrRe(r'tag2')): ANYOPTSTR}, got {'tag1': 'value1'}",
|
"expected tags to match {'tag1': 'bar', RemainingKeys(NotStrRe(r'tag2')): ANYOPTSTR}, got {'tag1': 'value1'}",
|
||||||
"expected tags to match {'tag1': 'bar', RemainingKeys(NotStrRe(r'tag2')): ANYOPTSTR}, got {'tag1': 'bar', 'tag2': ''}",
|
"expected tags to match {'tag1': 'bar', RemainingKeys(NotStrRe(r'tag2')): ANYOPTSTR}, got {'tag1': 'bar', 'tag2': ''}",
|
||||||
"expected tags to match {'tag1': 'bar', RemainingKeys(NotStrRe(r'tag2')): ANYOPTSTR}, got {'tag1': 'bar', 'tag2': 'baz'}",
|
"expected tags to match {'tag1': 'bar', RemainingKeys(NotStrRe(r'tag2')): ANYOPTSTR}, got {'tag1': 'bar', 'tag2': 'baz'}",
|
||||||
|
@ -345,7 +345,7 @@ MESSAGE_SPECS: List[Tuple[Dict, List[str], List[str], List[str]]] = [
|
||||||
],
|
],
|
||||||
# and they each error with:
|
# and they each error with:
|
||||||
[
|
[
|
||||||
"expected command to be PING, got PONG"
|
"expected command to match PING, got PONG"
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -8,6 +8,7 @@ import pytest
|
||||||
from irctest import cases, runner
|
from irctest import cases, runner
|
||||||
from irctest.client_mock import NoMessageException
|
from irctest.client_mock import NoMessageException
|
||||||
from irctest.numerics import (
|
from irctest.numerics import (
|
||||||
|
ERR_ERRONEUSNICKNAME,
|
||||||
RPL_ENDOFMONLIST,
|
RPL_ENDOFMONLIST,
|
||||||
RPL_MONLIST,
|
RPL_MONLIST,
|
||||||
RPL_MONOFFLINE,
|
RPL_MONOFFLINE,
|
||||||
|
@ -190,14 +191,15 @@ class MonitorTestCase(_BaseMonitorTestCase):
|
||||||
self.check_server_support()
|
self.check_server_support()
|
||||||
self.sendLine(1, "MONITOR + *!username@localhost")
|
self.sendLine(1, "MONITOR + *!username@localhost")
|
||||||
self.sendLine(1, "MONITOR + *!username@127.0.0.1")
|
self.sendLine(1, "MONITOR + *!username@127.0.0.1")
|
||||||
|
expected_command = StrRe(f"({RPL_MONOFFLINE}|{ERR_ERRONEUSNICKNAME})")
|
||||||
try:
|
try:
|
||||||
m = self.getMessage(1)
|
m = self.getMessage(1)
|
||||||
self.assertMessageMatch(m, command="731")
|
self.assertMessageMatch(m, command=expected_command)
|
||||||
except NoMessageException:
|
except NoMessageException:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
m = self.getMessage(1)
|
m = self.getMessage(1)
|
||||||
self.assertMessageMatch(m, command="731")
|
self.assertMessageMatch(m, command=expected_command)
|
||||||
self.connectClient("bar")
|
self.connectClient("bar")
|
||||||
try:
|
try:
|
||||||
m = self.getMessage(1)
|
m = self.getMessage(1)
|
||||||
|
|
Loading…
Reference in New Issue