mirror of
https://github.com/progval/irctest.git
synced 2025-04-04 22:39:50 +00:00
Use isort to order imports.
This commit is contained in:
@ -4,3 +4,8 @@ repos:
|
||||
hooks:
|
||||
- id: black
|
||||
language_version: python3.7
|
||||
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 5.5.2
|
||||
hooks:
|
||||
- id: isort
|
||||
|
@ -11,6 +11,9 @@ In short:
|
||||
* closing brackets/parentheses/... go on the same indent level as the line
|
||||
that opened them
|
||||
|
||||
You can use [pre-commit](https://pre-commit.com/) to automatically run it
|
||||
for you when you create a git commit.
|
||||
We also use `isort` to order imports (in short: just
|
||||
[follow PEP 8](https://www.python.org/dev/peps/pep-0008/#imports))
|
||||
|
||||
You can use [pre-commit](https://pre-commit.com/) to automatically run them
|
||||
when you create a git commit.
|
||||
Alternatively, run `pre-commit run -a`
|
||||
|
@ -2,11 +2,11 @@ import importlib
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import pytest
|
||||
import _pytest.unittest
|
||||
import pytest
|
||||
|
||||
from irctest.cases import _IrcTestCase, BaseClientTestCase, BaseServerTestCase
|
||||
from irctest.basecontrollers import BaseClientController, BaseServerController
|
||||
from irctest.cases import BaseClientTestCase, BaseServerTestCase, _IrcTestCase
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
|
@ -1,5 +1,5 @@
|
||||
import enum
|
||||
import collections
|
||||
import enum
|
||||
|
||||
|
||||
@enum.unique
|
||||
|
@ -1,9 +1,9 @@
|
||||
import os
|
||||
import shutil
|
||||
import socket
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
import subprocess
|
||||
|
||||
from .runner import NotImplementedByController
|
||||
|
||||
|
@ -1,28 +1,26 @@
|
||||
import ssl
|
||||
import time
|
||||
import socket
|
||||
import tempfile
|
||||
import unittest
|
||||
import functools
|
||||
import socket
|
||||
import ssl
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import pytest
|
||||
|
||||
from . import runner
|
||||
from . import client_mock
|
||||
from .irc_utils import capabilities
|
||||
from .irc_utils import message_parser
|
||||
from . import client_mock, runner
|
||||
from .exceptions import ConnectionClosed
|
||||
from .irc_utils import capabilities, message_parser
|
||||
from .irc_utils.junkdrawer import normalizeWhitespace, random_name
|
||||
from .irc_utils.sasl import sasl_plain_blob
|
||||
from .exceptions import ConnectionClosed
|
||||
from .specifications import Specifications
|
||||
from .numerics import (
|
||||
ERR_BADCHANNELKEY,
|
||||
ERR_BANNEDFROMCHAN,
|
||||
ERR_INVITEONLYCHAN,
|
||||
ERR_NEEDREGGEDNICK,
|
||||
ERR_NOSUCHCHANNEL,
|
||||
ERR_TOOMANYCHANNELS,
|
||||
ERR_BADCHANNELKEY,
|
||||
ERR_INVITEONLYCHAN,
|
||||
ERR_BANNEDFROMCHAN,
|
||||
ERR_NEEDREGGEDNICK,
|
||||
)
|
||||
from .specifications import Specifications
|
||||
|
||||
CHANNEL_JOIN_FAIL_NUMERICS = frozenset(
|
||||
[
|
||||
|
@ -1,9 +1,10 @@
|
||||
import socket
|
||||
import ssl
|
||||
import sys
|
||||
import time
|
||||
import socket
|
||||
|
||||
from .exceptions import ConnectionClosed, NoMessageException
|
||||
from .irc_utils import message_parser
|
||||
from .exceptions import NoMessageException, ConnectionClosed
|
||||
|
||||
|
||||
class ClientMock:
|
||||
|
@ -2,15 +2,14 @@ import base64
|
||||
import hashlib
|
||||
|
||||
import ecdsa
|
||||
from ecdsa.util import sigencode_der, sigdecode_der
|
||||
from ecdsa.util import sigdecode_der, sigencode_der
|
||||
|
||||
try:
|
||||
import pyxmpp2_scram as scram
|
||||
except ImportError:
|
||||
scram = None
|
||||
|
||||
from irctest import cases
|
||||
from irctest import authentication
|
||||
from irctest import authentication, cases
|
||||
from irctest.irc_utils.message_parser import Message
|
||||
|
||||
ECDSA_KEY = """
|
||||
|
@ -1,8 +1,7 @@
|
||||
import socket
|
||||
import ssl
|
||||
|
||||
from irctest import tls
|
||||
from irctest import cases
|
||||
from irctest import cases, tls
|
||||
from irctest.exceptions import ConnectionClosed
|
||||
from irctest.irc_utils.message_parser import Message
|
||||
|
||||
|
@ -1,13 +1,15 @@
|
||||
import os
|
||||
import time
|
||||
import shutil
|
||||
import tempfile
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
from irctest import client_mock
|
||||
from irctest import authentication
|
||||
from irctest.basecontrollers import NotImplementedByController
|
||||
from irctest.basecontrollers import BaseServerController, DirectoryBasedController
|
||||
from irctest import authentication, client_mock
|
||||
from irctest.basecontrollers import (
|
||||
BaseServerController,
|
||||
DirectoryBasedController,
|
||||
NotImplementedByController,
|
||||
)
|
||||
|
||||
TEMPLATE_CONFIG = """
|
||||
serverinfo {{
|
||||
|
@ -1,13 +1,15 @@
|
||||
import os
|
||||
import time
|
||||
import shutil
|
||||
import tempfile
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
from irctest import client_mock
|
||||
from irctest import authentication
|
||||
from irctest.basecontrollers import NotImplementedByController
|
||||
from irctest.basecontrollers import BaseServerController, DirectoryBasedController
|
||||
from irctest import authentication, client_mock
|
||||
from irctest.basecontrollers import (
|
||||
BaseServerController,
|
||||
DirectoryBasedController,
|
||||
NotImplementedByController,
|
||||
)
|
||||
|
||||
TEMPLATE_CONFIG = """
|
||||
serverinfo {{
|
||||
|
@ -1,12 +1,15 @@
|
||||
import os
|
||||
import time
|
||||
import shutil
|
||||
import tempfile
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
from irctest import authentication
|
||||
from irctest.basecontrollers import NotImplementedByController
|
||||
from irctest.basecontrollers import BaseServerController, DirectoryBasedController
|
||||
from irctest.basecontrollers import (
|
||||
BaseServerController,
|
||||
DirectoryBasedController,
|
||||
NotImplementedByController,
|
||||
)
|
||||
|
||||
TEMPLATE_CONFIG = """
|
||||
<bind address="{hostname}" port="{port}" type="clients">
|
||||
|
@ -1,10 +1,12 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from irctest import authentication
|
||||
from irctest import tls
|
||||
from irctest.basecontrollers import NotImplementedByController
|
||||
from irctest.basecontrollers import BaseClientController, DirectoryBasedController
|
||||
from irctest import authentication, tls
|
||||
from irctest.basecontrollers import (
|
||||
BaseClientController,
|
||||
DirectoryBasedController,
|
||||
NotImplementedByController,
|
||||
)
|
||||
|
||||
TEMPLATE_CONFIG = """
|
||||
supybot.directories.conf: {directory}/conf
|
||||
|
@ -1,9 +1,12 @@
|
||||
import os
|
||||
import time
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
from irctest.basecontrollers import NotImplementedByController
|
||||
from irctest.basecontrollers import BaseServerController, DirectoryBasedController
|
||||
from irctest.basecontrollers import (
|
||||
BaseServerController,
|
||||
DirectoryBasedController,
|
||||
NotImplementedByController,
|
||||
)
|
||||
|
||||
TEMPLATE_CONFIG = """
|
||||
clients:
|
||||
|
@ -3,8 +3,11 @@ import json
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from irctest.basecontrollers import NotImplementedByController
|
||||
from irctest.basecontrollers import BaseServerController, DirectoryBasedController
|
||||
from irctest.basecontrollers import (
|
||||
BaseServerController,
|
||||
DirectoryBasedController,
|
||||
NotImplementedByController,
|
||||
)
|
||||
|
||||
OPER_PWD = "frenchfries"
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
import os
|
||||
import tempfile
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
from irctest.basecontrollers import BaseClientController
|
||||
from irctest.basecontrollers import NotImplementedByController
|
||||
from irctest.basecontrollers import BaseClientController, NotImplementedByController
|
||||
|
||||
TEMPLATE_CONFIG = """
|
||||
[core]
|
||||
|
@ -1,7 +1,7 @@
|
||||
from collections import namedtuple
|
||||
import datetime
|
||||
import re
|
||||
import secrets
|
||||
from collections import namedtuple
|
||||
|
||||
HistoryMessage = namedtuple("HistoryMessage", ["time", "msgid", "target", "text"])
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import re
|
||||
import collections
|
||||
import re
|
||||
|
||||
from .junkdrawer import MultipleReplacer
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import unittest
|
||||
import operator
|
||||
import collections
|
||||
import operator
|
||||
import unittest
|
||||
|
||||
|
||||
class NotImplementedByController(unittest.SkipTest, NotImplementedError):
|
||||
|
@ -1,8 +1,6 @@
|
||||
from irctest import cases
|
||||
from irctest.irc_utils.sasl import sasl_plain_blob
|
||||
|
||||
from irctest.numerics import RPL_WELCOME
|
||||
from irctest.numerics import ERR_NICKNAMEINUSE
|
||||
from irctest.numerics import ERR_NICKNAMEINUSE, RPL_WELCOME
|
||||
|
||||
|
||||
class Bouncer(cases.BaseServerTestCase):
|
||||
|
@ -3,27 +3,23 @@ Section 3.2 of RFC 2812
|
||||
<https://tools.ietf.org/html/rfc2812#section-3.2>
|
||||
"""
|
||||
|
||||
from irctest import cases
|
||||
from irctest import client_mock
|
||||
from irctest import runner
|
||||
from irctest import cases, client_mock, runner
|
||||
from irctest.irc_utils import ambiguities
|
||||
from irctest.numerics import (
|
||||
ERR_BADCHANNELKEY,
|
||||
ERR_CANNOTSENDTOCHAN,
|
||||
ERR_CHANOPRIVSNEEDED,
|
||||
ERR_INVALIDMODEPARAM,
|
||||
ERR_INVITEONLYCHAN,
|
||||
ERR_NOSUCHCHANNEL,
|
||||
ERR_NOSUCHNICK,
|
||||
ERR_NOTONCHANNEL,
|
||||
ERR_UNKNOWNERROR,
|
||||
RPL_INVITING,
|
||||
RPL_NAMREPLY,
|
||||
RPL_NOTOPIC,
|
||||
RPL_TOPIC,
|
||||
RPL_TOPICTIME,
|
||||
RPL_NOTOPIC,
|
||||
RPL_NAMREPLY,
|
||||
RPL_INVITING,
|
||||
)
|
||||
from irctest.numerics import (
|
||||
ERR_NOSUCHCHANNEL,
|
||||
ERR_NOTONCHANNEL,
|
||||
ERR_CHANOPRIVSNEEDED,
|
||||
ERR_NOSUCHNICK,
|
||||
ERR_INVITEONLYCHAN,
|
||||
ERR_CANNOTSENDTOCHAN,
|
||||
ERR_BADCHANNELKEY,
|
||||
ERR_INVALIDMODEPARAM,
|
||||
ERR_UNKNOWNERROR,
|
||||
)
|
||||
|
||||
MODERN_CAPS = [
|
||||
|
@ -2,7 +2,7 @@ import secrets
|
||||
import time
|
||||
|
||||
from irctest import cases
|
||||
from irctest.irc_utils.junkdrawer import to_history_message, random_name
|
||||
from irctest.irc_utils.junkdrawer import random_name, to_history_message
|
||||
|
||||
CHATHISTORY_CAP = "draft/chathistory"
|
||||
EVENT_PLAYBACK_CAP = "draft/event-playback"
|
||||
|
@ -1,5 +1,5 @@
|
||||
from irctest import cases
|
||||
from irctest.numerics import RPL_WELCOME, ERR_NICKNAMEINUSE
|
||||
from irctest.numerics import ERR_NICKNAMEINUSE, RPL_WELCOME
|
||||
|
||||
|
||||
class ConfusablesTestCase(cases.BaseServerTestCase):
|
||||
|
@ -1,16 +1,25 @@
|
||||
from dataclasses import dataclass
|
||||
import re
|
||||
import time
|
||||
from dataclasses import dataclass
|
||||
|
||||
from irctest import cases
|
||||
|
||||
from irctest.numerics import RPL_LUSERCLIENT, RPL_LUSEROP, RPL_LUSERUNKNOWN, RPL_LUSERCHANNELS, RPL_LUSERME, RPL_LOCALUSERS, RPL_GLOBALUSERS, ERR_NOTREGISTERED
|
||||
from irctest.numerics import RPL_YOUREOPER
|
||||
from irctest.numerics import (
|
||||
ERR_NOTREGISTERED,
|
||||
RPL_GLOBALUSERS,
|
||||
RPL_LOCALUSERS,
|
||||
RPL_LUSERCHANNELS,
|
||||
RPL_LUSERCLIENT,
|
||||
RPL_LUSERME,
|
||||
RPL_LUSEROP,
|
||||
RPL_LUSERUNKNOWN,
|
||||
RPL_YOUREOPER,
|
||||
)
|
||||
|
||||
# 3 numbers, delimited by spaces, possibly negative (eek)
|
||||
LUSERCLIENT_REGEX = re.compile(r'^.*( [-0-9]* ).*( [-0-9]* ).*( [-0-9]* ).*$')
|
||||
LUSERCLIENT_REGEX = re.compile(r"^.*( [-0-9]* ).*( [-0-9]* ).*( [-0-9]* ).*$")
|
||||
# 2 numbers
|
||||
LUSERME_REGEX = re.compile(r'^.*( [-0-9]* ).*( [-0-9]* ).*$')
|
||||
LUSERME_REGEX = re.compile(r"^.*( [-0-9]* ).*( [-0-9]* ).*$")
|
||||
|
||||
|
||||
@dataclass
|
||||
class LusersResult:
|
||||
@ -25,10 +34,10 @@ class LusersResult:
|
||||
GlobalTotal: int = None
|
||||
GlobalMax: int = None
|
||||
|
||||
class LusersTestCase(cases.BaseServerTestCase):
|
||||
|
||||
class LusersTestCase(cases.BaseServerTestCase):
|
||||
def getLusers(self, client):
|
||||
self.sendLine(client, 'LUSERS')
|
||||
self.sendLine(client, "LUSERS")
|
||||
messages = self.getMessages(client)
|
||||
by_numeric = dict((msg.command, msg) for msg in messages)
|
||||
|
||||
@ -38,7 +47,7 @@ class LusersTestCase(cases.BaseServerTestCase):
|
||||
for message in messages:
|
||||
self.assertEqual(client, message.params[0])
|
||||
|
||||
luserclient = by_numeric[RPL_LUSERCLIENT] # 251
|
||||
luserclient = by_numeric[RPL_LUSERCLIENT] # 251
|
||||
self.assertEqual(len(luserclient.params), 2)
|
||||
luserclient_param = luserclient.params[1]
|
||||
try:
|
||||
@ -77,12 +86,12 @@ class LusersTestCase(cases.BaseServerTestCase):
|
||||
|
||||
return result
|
||||
|
||||
class BasicLusersTest(LusersTestCase):
|
||||
|
||||
@cases.SpecificationSelector.requiredBySpecification('RFC2812')
|
||||
class BasicLusersTest(LusersTestCase):
|
||||
@cases.SpecificationSelector.requiredBySpecification("RFC2812")
|
||||
def testLusers(self):
|
||||
self.connectClient('bar', name='bar')
|
||||
lusers = self.getLusers('bar')
|
||||
self.connectClient("bar", name="bar")
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertIn(lusers.Unregistered, (0, None))
|
||||
self.assertEqual(lusers.GlobalTotal, 1)
|
||||
self.assertEqual(lusers.GlobalMax, 1)
|
||||
@ -92,8 +101,8 @@ class BasicLusersTest(LusersTestCase):
|
||||
self.assertEqual(lusers.LocalTotal, 1)
|
||||
self.assertEqual(lusers.LocalMax, 1)
|
||||
|
||||
self.connectClient('qux', name='qux')
|
||||
lusers = self.getLusers('qux')
|
||||
self.connectClient("qux", name="qux")
|
||||
lusers = self.getLusers("qux")
|
||||
self.assertIn(lusers.Unregistered, (0, None))
|
||||
self.assertEqual(lusers.GlobalTotal, 2)
|
||||
self.assertEqual(lusers.GlobalMax, 2)
|
||||
@ -103,9 +112,9 @@ class BasicLusersTest(LusersTestCase):
|
||||
self.assertEqual(lusers.LocalTotal, 2)
|
||||
self.assertEqual(lusers.LocalMax, 2)
|
||||
|
||||
self.sendLine('qux', 'QUIT')
|
||||
self.assertDisconnected('qux')
|
||||
lusers = self.getLusers('bar')
|
||||
self.sendLine("qux", "QUIT")
|
||||
self.assertDisconnected("qux")
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertIn(lusers.Unregistered, (0, None))
|
||||
self.assertEqual(lusers.GlobalTotal, 1)
|
||||
self.assertEqual(lusers.GlobalMax, 2)
|
||||
@ -117,28 +126,27 @@ class BasicLusersTest(LusersTestCase):
|
||||
|
||||
|
||||
class LusersUnregisteredTestCase(LusersTestCase):
|
||||
|
||||
@cases.SpecificationSelector.requiredBySpecification('RFC2812')
|
||||
@cases.SpecificationSelector.requiredBySpecification("RFC2812")
|
||||
def testLusers(self):
|
||||
self.doLusersTest()
|
||||
|
||||
def _synchronize(self, client_name):
|
||||
"""Synchronizes using a PING, but accept ERR_NOTREGISTERED as a response."""
|
||||
self.sendLine(client_name, 'PING')
|
||||
self.sendLine(client_name, "PING")
|
||||
for _ in range(1000):
|
||||
msg = self.getRegistrationMessage(client_name)
|
||||
if msg.command in (ERR_NOTREGISTERED, 'PONG'):
|
||||
if msg.command in (ERR_NOTREGISTERED, "PONG"):
|
||||
break
|
||||
time.sleep(0.01)
|
||||
else:
|
||||
assert False, (
|
||||
'Sent a PING before registration, '
|
||||
'got neither PONG or ERR_NOTREGISTERED'
|
||||
"Sent a PING before registration, "
|
||||
"got neither PONG or ERR_NOTREGISTERED"
|
||||
)
|
||||
|
||||
def doLusersTest(self):
|
||||
self.connectClient('bar', name='bar')
|
||||
lusers = self.getLusers('bar')
|
||||
self.connectClient("bar", name="bar")
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertIn(lusers.Unregistered, (0, None))
|
||||
self.assertEqual(lusers.GlobalTotal, 1)
|
||||
self.assertEqual(lusers.GlobalMax, 1)
|
||||
@ -148,10 +156,10 @@ class LusersUnregisteredTestCase(LusersTestCase):
|
||||
self.assertEqual(lusers.LocalTotal, 1)
|
||||
self.assertEqual(lusers.LocalMax, 1)
|
||||
|
||||
self.addClient('qux')
|
||||
self.sendLine('qux', 'NICK qux')
|
||||
self._synchronize('qux')
|
||||
lusers = self.getLusers('bar')
|
||||
self.addClient("qux")
|
||||
self.sendLine("qux", "NICK qux")
|
||||
self._synchronize("qux")
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertEqual(lusers.Unregistered, 1)
|
||||
self.assertEqual(lusers.GlobalTotal, 1)
|
||||
self.assertEqual(lusers.GlobalMax, 1)
|
||||
@ -161,10 +169,10 @@ class LusersUnregisteredTestCase(LusersTestCase):
|
||||
self.assertEqual(lusers.LocalTotal, 1)
|
||||
self.assertEqual(lusers.LocalMax, 1)
|
||||
|
||||
self.addClient('bat')
|
||||
self.sendLine('bat', 'NICK bat')
|
||||
self._synchronize('bat')
|
||||
lusers = self.getLusers('bar')
|
||||
self.addClient("bat")
|
||||
self.sendLine("bat", "NICK bat")
|
||||
self._synchronize("bat")
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertEqual(lusers.Unregistered, 2)
|
||||
self.assertEqual(lusers.GlobalTotal, 1)
|
||||
self.assertEqual(lusers.GlobalMax, 1)
|
||||
@ -175,9 +183,9 @@ class LusersUnregisteredTestCase(LusersTestCase):
|
||||
self.assertEqual(lusers.LocalMax, 1)
|
||||
|
||||
# complete registration on one client
|
||||
self.sendLine('qux', 'USER u s e r')
|
||||
self.getMessages('qux')
|
||||
lusers = self.getLusers('bar')
|
||||
self.sendLine("qux", "USER u s e r")
|
||||
self.getMessages("qux")
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertEqual(lusers.Unregistered, 1)
|
||||
self.assertEqual(lusers.GlobalTotal, 2)
|
||||
self.assertEqual(lusers.GlobalMax, 2)
|
||||
@ -188,9 +196,9 @@ class LusersUnregisteredTestCase(LusersTestCase):
|
||||
self.assertEqual(lusers.LocalMax, 2)
|
||||
|
||||
# QUIT the other without registering
|
||||
self.sendLine('bat', 'QUIT')
|
||||
self.assertDisconnected('bat')
|
||||
lusers = self.getLusers('bar')
|
||||
self.sendLine("bat", "QUIT")
|
||||
self.assertDisconnected("bat")
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertIn(lusers.Unregistered, (0, None))
|
||||
self.assertEqual(lusers.GlobalTotal, 2)
|
||||
self.assertEqual(lusers.GlobalMax, 2)
|
||||
@ -203,18 +211,19 @@ class LusersUnregisteredTestCase(LusersTestCase):
|
||||
|
||||
class LusersUnregisteredDefaultInvisibleTest(LusersUnregisteredTestCase):
|
||||
"""Same as above but with +i as the default."""
|
||||
|
||||
@staticmethod
|
||||
def config():
|
||||
return {
|
||||
"oragono_config": lambda config: config['accounts'].update(
|
||||
{'default-user-modes': '+i'}
|
||||
"oragono_config": lambda config: config["accounts"].update(
|
||||
{"default-user-modes": "+i"}
|
||||
)
|
||||
}
|
||||
|
||||
@cases.SpecificationSelector.requiredBySpecification('Oragono')
|
||||
@cases.SpecificationSelector.requiredBySpecification("Oragono")
|
||||
def testLusers(self):
|
||||
self.doLusersTest()
|
||||
lusers = self.getLusers('bar')
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertEqual(lusers.Unregistered, 0)
|
||||
self.assertEqual(lusers.GlobalTotal, 2)
|
||||
self.assertEqual(lusers.GlobalMax, 2)
|
||||
@ -225,11 +234,10 @@ class LusersUnregisteredDefaultInvisibleTest(LusersUnregisteredTestCase):
|
||||
|
||||
|
||||
class LuserOpersTest(LusersTestCase):
|
||||
|
||||
@cases.SpecificationSelector.requiredBySpecification('Oragono')
|
||||
@cases.SpecificationSelector.requiredBySpecification("Oragono")
|
||||
def testLuserOpers(self):
|
||||
self.connectClient('bar', name='bar')
|
||||
lusers = self.getLusers('bar')
|
||||
self.connectClient("bar", name="bar")
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertEqual(lusers.GlobalTotal, 1)
|
||||
self.assertEqual(lusers.GlobalMax, 1)
|
||||
self.assertGreaterEqual(lusers.GlobalInvisible, 0)
|
||||
@ -240,10 +248,10 @@ class LuserOpersTest(LusersTestCase):
|
||||
self.assertIn(lusers.Opers, (0, None))
|
||||
|
||||
# add 1 oper
|
||||
self.sendLine('bar', 'OPER root frenchfries')
|
||||
msgs = self.getMessages('bar')
|
||||
self.sendLine("bar", "OPER root frenchfries")
|
||||
msgs = self.getMessages("bar")
|
||||
self.assertIn(RPL_YOUREOPER, {msg.command for msg in msgs})
|
||||
lusers = self.getLusers('bar')
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertEqual(lusers.GlobalTotal, 1)
|
||||
self.assertEqual(lusers.GlobalMax, 1)
|
||||
self.assertGreaterEqual(lusers.GlobalInvisible, 0)
|
||||
@ -254,10 +262,10 @@ class LuserOpersTest(LusersTestCase):
|
||||
self.assertEqual(lusers.Opers, 1)
|
||||
|
||||
# now 2 opers
|
||||
self.connectClient('qux', name='qux')
|
||||
self.sendLine('qux', 'OPER root frenchfries')
|
||||
self.getMessages('qux')
|
||||
lusers = self.getLusers('bar')
|
||||
self.connectClient("qux", name="qux")
|
||||
self.sendLine("qux", "OPER root frenchfries")
|
||||
self.getMessages("qux")
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertEqual(lusers.GlobalTotal, 2)
|
||||
self.assertEqual(lusers.GlobalMax, 2)
|
||||
self.assertGreaterEqual(lusers.GlobalInvisible, 0)
|
||||
@ -268,10 +276,10 @@ class LuserOpersTest(LusersTestCase):
|
||||
self.assertEqual(lusers.Opers, 2)
|
||||
|
||||
# remove oper with MODE
|
||||
self.sendLine('bar', 'MODE bar -o')
|
||||
msgs = self.getMessages('bar')
|
||||
self.assertIn('MODE', {msg.command for msg in msgs})
|
||||
lusers = self.getLusers('bar')
|
||||
self.sendLine("bar", "MODE bar -o")
|
||||
msgs = self.getMessages("bar")
|
||||
self.assertIn("MODE", {msg.command for msg in msgs})
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertEqual(lusers.GlobalTotal, 2)
|
||||
self.assertEqual(lusers.GlobalMax, 2)
|
||||
self.assertGreaterEqual(lusers.GlobalInvisible, 0)
|
||||
@ -282,9 +290,9 @@ class LuserOpersTest(LusersTestCase):
|
||||
self.assertEqual(lusers.Opers, 1)
|
||||
|
||||
# remove oper by quit
|
||||
self.sendLine('qux', 'QUIT')
|
||||
self.assertDisconnected('qux')
|
||||
lusers = self.getLusers('bar')
|
||||
self.sendLine("qux", "QUIT")
|
||||
self.assertDisconnected("qux")
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertEqual(lusers.GlobalTotal, 1)
|
||||
self.assertEqual(lusers.GlobalMax, 2)
|
||||
self.assertGreaterEqual(lusers.GlobalInvisible, 0)
|
||||
@ -299,15 +307,15 @@ class OragonoInvisibleDefaultTest(LusersTestCase):
|
||||
@staticmethod
|
||||
def config():
|
||||
return {
|
||||
"oragono_config": lambda config: config['accounts'].update(
|
||||
{'default-user-modes': '+i'}
|
||||
"oragono_config": lambda config: config["accounts"].update(
|
||||
{"default-user-modes": "+i"}
|
||||
)
|
||||
}
|
||||
|
||||
@cases.SpecificationSelector.requiredBySpecification('Oragono')
|
||||
@cases.SpecificationSelector.requiredBySpecification("Oragono")
|
||||
def testLusers(self):
|
||||
self.connectClient('bar', name='bar')
|
||||
lusers = self.getLusers('bar')
|
||||
self.connectClient("bar", name="bar")
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertEqual(lusers.GlobalTotal, 1)
|
||||
self.assertEqual(lusers.GlobalMax, 1)
|
||||
self.assertEqual(lusers.GlobalInvisible, 1)
|
||||
@ -315,8 +323,8 @@ class OragonoInvisibleDefaultTest(LusersTestCase):
|
||||
self.assertEqual(lusers.LocalTotal, 1)
|
||||
self.assertEqual(lusers.LocalMax, 1)
|
||||
|
||||
self.connectClient('qux', name='qux')
|
||||
lusers = self.getLusers('qux')
|
||||
self.connectClient("qux", name="qux")
|
||||
lusers = self.getLusers("qux")
|
||||
self.assertEqual(lusers.GlobalTotal, 2)
|
||||
self.assertEqual(lusers.GlobalMax, 2)
|
||||
self.assertEqual(lusers.GlobalInvisible, 2)
|
||||
@ -325,10 +333,10 @@ class OragonoInvisibleDefaultTest(LusersTestCase):
|
||||
self.assertEqual(lusers.LocalMax, 2)
|
||||
|
||||
# remove +i with MODE
|
||||
self.sendLine('bar', 'MODE bar -i')
|
||||
msgs = self.getMessages('bar')
|
||||
lusers = self.getLusers('bar')
|
||||
self.assertIn('MODE', {msg.command for msg in msgs})
|
||||
self.sendLine("bar", "MODE bar -i")
|
||||
msgs = self.getMessages("bar")
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertIn("MODE", {msg.command for msg in msgs})
|
||||
self.assertEqual(lusers.GlobalTotal, 2)
|
||||
self.assertEqual(lusers.GlobalMax, 2)
|
||||
self.assertEqual(lusers.GlobalInvisible, 1)
|
||||
@ -337,9 +345,9 @@ class OragonoInvisibleDefaultTest(LusersTestCase):
|
||||
self.assertEqual(lusers.LocalMax, 2)
|
||||
|
||||
# disconnect invisible user
|
||||
self.sendLine('qux', 'QUIT')
|
||||
self.assertDisconnected('qux')
|
||||
lusers = self.getLusers('bar')
|
||||
self.sendLine("qux", "QUIT")
|
||||
self.assertDisconnected("qux")
|
||||
lusers = self.getLusers("bar")
|
||||
self.assertEqual(lusers.GlobalTotal, 1)
|
||||
self.assertEqual(lusers.GlobalMax, 2)
|
||||
self.assertEqual(lusers.GlobalInvisible, 0)
|
||||
|
@ -3,13 +3,13 @@
|
||||
"""
|
||||
|
||||
from irctest import cases
|
||||
from irctest.client_mock import NoMessageException
|
||||
from irctest.basecontrollers import NotImplementedByController
|
||||
from irctest.client_mock import NoMessageException
|
||||
from irctest.numerics import (
|
||||
RPL_MONLIST,
|
||||
RPL_ENDOFMONLIST,
|
||||
RPL_MONONLINE,
|
||||
RPL_MONLIST,
|
||||
RPL_MONOFFLINE,
|
||||
RPL_MONONLINE,
|
||||
)
|
||||
|
||||
|
||||
|
@ -4,16 +4,16 @@ from irctest import cases
|
||||
class ReadqTestCase(cases.BaseServerTestCase):
|
||||
"""Test responses to DoS attacks using long lines."""
|
||||
|
||||
@cases.SpecificationSelector.requiredBySpecification('Oragono')
|
||||
@cases.SpecificationSelector.requiredBySpecification("Oragono")
|
||||
def testReadqTags(self):
|
||||
self.connectClient('mallory', name='mallory', capabilities=['message-tags'])
|
||||
self.joinChannel('mallory', '#test')
|
||||
self.sendLine('mallory', 'PRIVMSG #test ' + 'a' * 16384)
|
||||
self.assertDisconnected('mallory')
|
||||
self.connectClient("mallory", name="mallory", capabilities=["message-tags"])
|
||||
self.joinChannel("mallory", "#test")
|
||||
self.sendLine("mallory", "PRIVMSG #test " + "a" * 16384)
|
||||
self.assertDisconnected("mallory")
|
||||
|
||||
@cases.SpecificationSelector.requiredBySpecification('Oragono')
|
||||
@cases.SpecificationSelector.requiredBySpecification("Oragono")
|
||||
def testReadqNoTags(self):
|
||||
self.connectClient('mallory', name='mallory')
|
||||
self.joinChannel('mallory', '#test')
|
||||
self.sendLine('mallory', 'PRIVMSG #test ' + 'a' * 16384)
|
||||
self.assertDisconnected('mallory')
|
||||
self.connectClient("mallory", name="mallory")
|
||||
self.joinChannel("mallory", "#test")
|
||||
self.sendLine("mallory", "PRIVMSG #test " + "a" * 16384)
|
||||
self.assertDisconnected("mallory")
|
||||
|
@ -3,7 +3,6 @@ Regression tests for bugs in oragono.
|
||||
"""
|
||||
|
||||
from irctest import cases
|
||||
|
||||
from irctest.numerics import ERR_ERRONEUSNICKNAME, ERR_NICKNAMEINUSE, RPL_WELCOME
|
||||
|
||||
|
||||
|
@ -2,7 +2,6 @@ from irctest import cases
|
||||
from irctest.irc_utils.junkdrawer import random_name
|
||||
from irctest.server_tests.test_chathistory import CHATHISTORY_CAP, EVENT_PLAYBACK_CAP
|
||||
|
||||
|
||||
RELAYMSG_CAP = "draft/relaymsg"
|
||||
RELAYMSG_TAG_NAME = "draft/relaymsg"
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
import secrets
|
||||
|
||||
from irctest import cases
|
||||
|
||||
from irctest.numerics import RPL_AWAY
|
||||
|
||||
ANCIENT_TIMESTAMP = "2006-01-02T15:04:05.999Z"
|
||||
|
@ -1,6 +1,6 @@
|
||||
from irctest import cases
|
||||
from irctest.numerics import ERR_CANNOTSENDRP
|
||||
from irctest.irc_utils.junkdrawer import random_name
|
||||
from irctest.numerics import ERR_CANNOTSENDRP
|
||||
|
||||
|
||||
class RoleplayTestCase(cases.BaseServerTestCase):
|
||||
|
@ -5,11 +5,11 @@ User commands as specified in Section 3.6 of RFC 2812:
|
||||
|
||||
from irctest import cases
|
||||
from irctest.numerics import (
|
||||
RPL_WHOISUSER,
|
||||
RPL_WHOISCHANNELS,
|
||||
RPL_AWAY,
|
||||
RPL_NOWAWAY,
|
||||
RPL_UNAWAY,
|
||||
RPL_WHOISCHANNELS,
|
||||
RPL_WHOISUSER,
|
||||
)
|
||||
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
import time
|
||||
|
||||
from irctest import cases
|
||||
from irctest.irc_utils.junkdrawer import ircv3_timestamp_to_unixtime
|
||||
from irctest.irc_utils.junkdrawer import to_history_message
|
||||
from irctest.irc_utils.junkdrawer import random_name
|
||||
from irctest.irc_utils.junkdrawer import (
|
||||
ircv3_timestamp_to_unixtime,
|
||||
random_name,
|
||||
to_history_message,
|
||||
)
|
||||
|
||||
|
||||
def extract_playback_privmsgs(messages):
|
||||
|
@ -1,2 +1,11 @@
|
||||
[tool.black]
|
||||
target-version = ['py37']
|
||||
|
||||
[tool.isort]
|
||||
multi_line_output = 3
|
||||
include_trailing_comma = true
|
||||
force_grid_wrap = 0
|
||||
use_parentheses = true
|
||||
ensure_newline_before_comments = true
|
||||
line_length = 88
|
||||
force_sort_within_sections = true
|
||||
|
Reference in New Issue
Block a user