From 5221cc9bc5a8e7e944115898a3a59168cb0553de Mon Sep 17 00:00:00 2001 From: Daisie Huang Date: Wed, 2 Oct 2024 14:27:08 -0700 Subject: [PATCH] Update test_uniform_federation.py --- tests/test_uniform_federation.py | 74 +++----------------------------- 1 file changed, 5 insertions(+), 69 deletions(-) diff --git a/tests/test_uniform_federation.py b/tests/test_uniform_federation.py index 3ffb2e3..682b301 100644 --- a/tests/test_uniform_federation.py +++ b/tests/test_uniform_federation.py @@ -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) @@ -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) ): @@ -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"]