mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-15 05:54:11 +02:00
epplibwrapper test_client
This commit is contained in:
parent
6c8ec6044b
commit
4e00124fdd
1 changed files with 80 additions and 75 deletions
|
@ -26,6 +26,7 @@ class TestClient(TestCase):
|
|||
|
||||
def fake_result(self, code, msg):
|
||||
"""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")
|
||||
|
||||
@patch("epplibwrapper.client.Client")
|
||||
|
@ -268,6 +269,7 @@ class TestClient(TestCase):
|
|||
Raises a ConcurrentObjectUseError, which gevent throws when accessing
|
||||
the same thread from two different locations.
|
||||
"""
|
||||
with less_console_noise():
|
||||
# This error is thrown when two threads are being used concurrently
|
||||
raise ConcurrentObjectUseError("This socket is already used by another greenlet")
|
||||
|
||||
|
@ -281,6 +283,7 @@ class TestClient(TestCase):
|
|||
"""
|
||||
Simulates receiving a success response from EPP.
|
||||
"""
|
||||
with less_console_noise():
|
||||
mock = MagicMock(
|
||||
code=1000,
|
||||
msg="Command completed successfully",
|
||||
|
@ -296,12 +299,14 @@ class TestClient(TestCase):
|
|||
"""
|
||||
Simulates receiving a response by reading from a predefined XML file.
|
||||
"""
|
||||
with less_console_noise():
|
||||
location = Path(__file__).parent / "utility" / "infoDomain.xml"
|
||||
xml = (location).read_bytes()
|
||||
return xml
|
||||
|
||||
def get_fake_epp_result(self):
|
||||
"""Mimics a return from EPP by returning a dictionary in the same format"""
|
||||
with less_console_noise():
|
||||
result = {
|
||||
"cl_tr_id": None,
|
||||
"code": 1000,
|
||||
|
@ -350,7 +355,7 @@ class TestClient(TestCase):
|
|||
- Subsequently, the client re-initializes the connection.
|
||||
- A retry of the command execution post-reinitialization succeeds.
|
||||
"""
|
||||
|
||||
with less_console_noise():
|
||||
expected_result = self.get_fake_epp_result()
|
||||
wrapper = None
|
||||
# Trigger a retry
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue