Skip to content

Commit

Permalink
Update test_uniform_federation.py
Browse files Browse the repository at this point in the history
  • Loading branch information
daisieh committed Oct 2, 2024
1 parent 697908d commit 5221cc9
Showing 1 changed file with 5 additions and 69 deletions.
74 changes: 5 additions & 69 deletions tests/test_uniform_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,72 +360,6 @@ def test_valid_asyncRequests_two_servers_post(mock_requests, client, two_servers
assert Success == [200, 200]


@patch('federation.requests.post', side_effect=exceptions.ConnectionError)
def test_invalid_asyncRequests_two_servers_get(mock_requests, client, two_servers):
with client:
FR = get_federation_response("POST")
resp = FR.async_requests(request='GET',
endpoint_path=TestParams["path"],
endpoint_payload="",
header=TestParams["Headers"],
endpoint_service=TestParams["service"])
ConnErrs = list(map(lambda a: "ConnectionError" in str(a), resp.values()))

# Error should just be propagated through since handle_server_request will address it

assert len(resp) == 2
assert ConnErrs == [True, True]


@patch('federation.requests.post', side_effect=exceptions.ConnectionError)
def test_invalid_asyncRequests_two_servers_post(mock_requests, client, two_servers):
with client:
FR = get_federation_response("POST")
resp = FR.async_requests(request='POST',
endpoint_path=TestParams["path"],
endpoint_payload="",
header=TestParams["Headers"],
endpoint_service=TestParams["service"])

Success = list(map(lambda a: "ConnectionError" in str(a), resp.values()))

assert len(resp) == 2
assert Success == [True, True]


@patch('federation.requests.post', side_effect=exceptions.Timeout)
def test_timeout_asyncRequests_two_servers_post(mock_requests, client, two_servers):
with client:
FR = get_federation_response("POST")
resp = FR.async_requests(request='POST',
endpoint_path=TestParams["path"],
endpoint_payload="",
header=TestParams["Headers"],
endpoint_service=TestParams["service"])

Success = list(map(lambda a: "Timeout" in str(a), resp.values()))

assert len(resp) == 2
assert Success == [True, True]


@patch('federation.requests.post', side_effect=exceptions.Timeout)
def test_timeout_asyncRequests_two_servers_get(mock_requests, client, two_servers):
with client:
FR = get_federation_response("GET")
resp = FR.async_requests(request='GET',
endpoint_path=TestParams["path"],
endpoint_payload="",
header=TestParams["Headers"],
endpoint_service=TestParams["service"])

TimeoutErrs = list(map(lambda a: "Timeout" in str(a), resp.values()))

# Error should just be propagated through since handle_server_request will address it

assert len(resp) == 2
assert TimeoutErrs == [True, True]

# Test Federation with one server --------------------------------------------------------------------

@patch('federation.requests.Session.get', side_effect=mocked_service_get)
Expand All @@ -448,7 +382,8 @@ def test_valid_federated_query_one_server_get(mock_requests, mock_session, clien
data=json.dumps({"path": TestParams["path"],
"payload": "",
"method": "GET",
"service": TestParams["service"]
"service": TestParams["service"],
"unsafe": True
}),
headers=Headers(fedHeader.headers)
):
Expand Down Expand Up @@ -481,11 +416,12 @@ def test_valid_federated_query_one_server_post(mock_requests, mock_session, clie
data=json.dumps({"path": TestParams["path"],
"payload": "",
"method": "POST",
"service": TestParams["service"]}),
"service": TestParams["service"]},
"unsafe": True),
headers=Headers(fedHeader.headers)
):
RO, Status = operations.post_search()

print(f"hlo {RO}")
assert Status == 200
for server in RO:
loc = server["location"]["name"]
Expand Down

0 comments on commit 5221cc9

Please sign in to comment.