updated linter length; linter reformatted several files

This commit is contained in:
David Kennedy 2023-11-10 11:05:18 -05:00
parent f0636013e0
commit c760417e6a
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
65 changed files with 550 additions and 1727 deletions

View file

@ -95,9 +95,7 @@ class EPPLibWrapper:
try:
if not self.pool_status.connection_success:
raise LoginError(
"Couldn't connect to the registry after three attempts"
)
raise LoginError("Couldn't connect to the registry after three attempts")
with self._pool.get() as connection:
response = connection.send(command)
except Timeout as t:
@ -239,6 +237,4 @@ try:
logger.info("registry client initialized")
except Exception:
CLIENT = None # type: ignore
logger.warning(
"Unable to configure epplib. Registrar cannot contact registry.", exc_info=True
)
logger.warning("Unable to configure epplib. Registrar cannot contact registry.", exc_info=True)

View file

@ -103,9 +103,7 @@ class TestConnectionPool(TestCase):
],
cl_id="gov2023-ote",
cr_id="gov2023-ote",
cr_date=datetime.datetime(
2023, 8, 15, 23, 56, 36, tzinfo=tzlocal()
),
cr_date=datetime.datetime(2023, 8, 15, 23, 56, 36, tzinfo=tzlocal()),
up_id="gov2023-ote",
up_date=datetime.datetime(2023, 8, 17, 2, 3, 19, tzinfo=tzlocal()),
tr_date=None,
@ -129,9 +127,7 @@ class TestConnectionPool(TestCase):
# Mock what happens inside the "with"
with ExitStack() as stack:
stack.enter_context(
patch.object(EPPConnectionPool, "_create_socket", self.fake_socket)
)
stack.enter_context(patch.object(EPPConnectionPool, "_create_socket", self.fake_socket))
stack.enter_context(patch.object(Socket, "connect", self.fake_client))
stack.enter_context(patch.object(SocketTransport, "send", self.fake_send))
stack.enter_context(patch.object(SocketTransport, "receive", fake_receive))
@ -176,9 +172,7 @@ class TestConnectionPool(TestCase):
],
cl_id="gov2023-ote",
cr_id="gov2023-ote",
cr_date=datetime.datetime(
2023, 8, 15, 23, 56, 36, tzinfo=tzlocal()
),
cr_date=datetime.datetime(2023, 8, 15, 23, 56, 36, tzinfo=tzlocal()),
up_id="gov2023-ote",
up_date=datetime.datetime(2023, 8, 17, 2, 3, 19, tzinfo=tzlocal()),
tr_date=None,
@ -202,9 +196,7 @@ class TestConnectionPool(TestCase):
# Mock what happens inside the "with"
with ExitStack() as stack:
stack.enter_context(
patch.object(EPPConnectionPool, "_create_socket", self.fake_socket)
)
stack.enter_context(patch.object(EPPConnectionPool, "_create_socket", self.fake_socket))
stack.enter_context(patch.object(Socket, "connect", self.fake_client))
stack.enter_context(patch.object(SocketTransport, "send", self.fake_send))
stack.enter_context(patch.object(SocketTransport, "receive", fake_receive))
@ -218,9 +210,7 @@ class TestConnectionPool(TestCase):
# that they cannot connect to EPP
with self.assertRaises(RegistryError):
expected = "InfoDomain failed to execute due to a connection error."
result = registry.send(
commands.InfoDomain(name="test.gov"), cleaned=True
)
result = registry.send(commands.InfoDomain(name="test.gov"), cleaned=True)
self.assertEqual(result, expected)
# A subsequent command should be successful, as the pool restarts
@ -240,9 +230,7 @@ class TestConnectionPool(TestCase):
right as we send a command."""
with ExitStack() as stack:
stack.enter_context(
patch.object(EPPConnectionPool, "_create_socket", self.fake_socket)
)
stack.enter_context(patch.object(EPPConnectionPool, "_create_socket", self.fake_socket))
stack.enter_context(patch.object(Socket, "connect", self.fake_client))
# Pool should be running
@ -252,7 +240,5 @@ class TestConnectionPool(TestCase):
# Try to send a command out - should fail
with self.assertRaises(RegistryError):
expected = "InfoDomain failed to execute due to a connection error."
result = registry.send(
commands.InfoDomain(name="test.gov"), cleaned=True
)
result = registry.send(commands.InfoDomain(name="test.gov"), cleaned=True)
self.assertEqual(result, expected)

View file

@ -125,9 +125,7 @@ class EPPConnectionPool(ConnectionPool):
# Open multiple connections
for i in range(self.size):
self.greenlets.append(
gevent.spawn_later(self.spawn_frequency * i, self._addOne)
)
self.greenlets.append(gevent.spawn_later(self.spawn_frequency * i, self._addOne))
# Open a "keepalive" thread if we want to ping open connections
if self.keepalive:

View file

@ -28,14 +28,8 @@ class PoolError(Exception):
# Used variables due to linter requirements
kill_failed = "Could not kill all connections. Are multiple pools running?"
conn_failed = (
"Failed to execute due to a registry error."
" See previous logs to determine the cause of the error."
)
alive_failed = (
"Failed to keep the connection alive. "
"It is likely that the registry returned a LoginError."
)
conn_failed = "Failed to execute due to a registry error. See previous logs to determine the cause of the error."
alive_failed = "Failed to keep the connection alive. It is likely that the registry returned a LoginError."
_error_mapping = {
PoolErrorCodes.KILL_ALL_FAILED: kill_failed,
PoolErrorCodes.NEW_CONNECTION_FAILED: conn_failed,