epplibwrapper test_client

This commit is contained in:
David Kennedy 2024-07-05 14:25:03 -04:00
parent 6c8ec6044b
commit 4e00124fdd
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B

View file

@ -26,6 +26,7 @@ class TestClient(TestCase):
def fake_result(self, code, msg): def fake_result(self, code, msg):
"""Helper function to create a fake Result object""" """Helper function to create a fake Result object"""
with less_console_noise():
return Result(code=code, msg=msg, res_data=[], cl_tr_id="cl_tr_id", sv_tr_id="sv_tr_id") return Result(code=code, msg=msg, res_data=[], cl_tr_id="cl_tr_id", sv_tr_id="sv_tr_id")
@patch("epplibwrapper.client.Client") @patch("epplibwrapper.client.Client")
@ -268,6 +269,7 @@ class TestClient(TestCase):
Raises a ConcurrentObjectUseError, which gevent throws when accessing Raises a ConcurrentObjectUseError, which gevent throws when accessing
the same thread from two different locations. the same thread from two different locations.
""" """
with less_console_noise():
# This error is thrown when two threads are being used concurrently # This error is thrown when two threads are being used concurrently
raise ConcurrentObjectUseError("This socket is already used by another greenlet") raise ConcurrentObjectUseError("This socket is already used by another greenlet")
@ -281,6 +283,7 @@ class TestClient(TestCase):
""" """
Simulates receiving a success response from EPP. Simulates receiving a success response from EPP.
""" """
with less_console_noise():
mock = MagicMock( mock = MagicMock(
code=1000, code=1000,
msg="Command completed successfully", msg="Command completed successfully",
@ -296,12 +299,14 @@ class TestClient(TestCase):
""" """
Simulates receiving a response by reading from a predefined XML file. Simulates receiving a response by reading from a predefined XML file.
""" """
with less_console_noise():
location = Path(__file__).parent / "utility" / "infoDomain.xml" location = Path(__file__).parent / "utility" / "infoDomain.xml"
xml = (location).read_bytes() xml = (location).read_bytes()
return xml return xml
def get_fake_epp_result(self): def get_fake_epp_result(self):
"""Mimics a return from EPP by returning a dictionary in the same format""" """Mimics a return from EPP by returning a dictionary in the same format"""
with less_console_noise():
result = { result = {
"cl_tr_id": None, "cl_tr_id": None,
"code": 1000, "code": 1000,
@ -350,7 +355,7 @@ class TestClient(TestCase):
- Subsequently, the client re-initializes the connection. - Subsequently, the client re-initializes the connection.
- A retry of the command execution post-reinitialization succeeds. - A retry of the command execution post-reinitialization succeeds.
""" """
with less_console_noise():
expected_result = self.get_fake_epp_result() expected_result = self.get_fake_epp_result()
wrapper = None wrapper = None
# Trigger a retry # Trigger a retry