diff --git a/tests/test_uniform_federation.py b/tests/test_uniform_federation.py index ba0d276..ef3a4d7 100644 --- a/tests/test_uniform_federation.py +++ b/tests/test_uniform_federation.py @@ -421,7 +421,6 @@ def test_valid_federated_query_one_server_post(mock_requests, mock_session, clie headers=Headers(fedHeader.headers) ): RO, Status = operations.post_search() - print(f"hlo {RO}") assert Status == 200 for server in RO: loc = server["location"]["name"] @@ -429,171 +428,6 @@ def test_valid_federated_query_one_server_post(mock_requests, mock_session, clie assert server['results'] == PostResponse[loc]['results'] -# Test Federation with one server, have "local" error ------------------------------------------------- - -@patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.requests.post', side_effect=mocked_async_local_ConnErr_requests_post) -def test_valid_federated_local_ConnErr_one_server_post(mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "POST", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server['results'] == PostResponse[loc]['results'] - - -@patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.requests.post', side_effect=mocked_async_local_timeout_requests_post) -def test_valid_federated_local_TimeOut_one_server_post(mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "POST", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - if server["status"] == 200: - assert server['results'] == PostResponse[loc]['results'] - - - -@patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.requests.post', side_effect=mocked_async_local_timeout_requests_get) -def test_valid_federated_local_TimeOut_one_server_get(mock_requests, mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "GET", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == GetResponse[loc]['results'] - - -@patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.requests.post', side_effect=mocked_async_local_ConnErr_requests_get) -def test_valid_federated_local_ConnErr_one_server_get(mock_requests, mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path" : TestParams["path"], - "payload": "", - "method" : "GET", - "service": TestParams["service"] - }), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == GetResponse[loc]['results'] - - -# Test Federation with one server, have server error out -------------------------------------------------- - -@patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.requests.post', side_effect=mocked_async_p1_ConnErr_requests_post) -def test_ConnErr_federated_valid_local_one_server_post(mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "POST", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == PostResponse[loc]['results'] - -@patch('federation.requests.Session.post', side_effect=mocked_service_post) -@patch('federation.requests.post', side_effect=mocked_async_p1_timeout_requests_post) -def test_TimeOut_federated_valid_local_one_server_post(mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "POST", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == PostResponse[loc]['results'] - - -@patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.requests.post', side_effect=mocked_async_p1_ConnErr_requests_get) -def test_ConnErr_federated_valid_local_one_server_get(mock_requests, mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "GET", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == GetResponse[loc]['results'] - - -@patch('federation.requests.Session.get', side_effect=mocked_service_get) -@patch('federation.requests.post', side_effect=mocked_async_p1_ConnErr_requests_get) -def test_TimeOut_federated_valid_local_one_server_get(mock_requests, mock_session, client, two_servers): - with client: - with APP.app.test_request_context( - data=json.dumps({"path": TestParams["path"], - "payload": "", - "method": "GET", - "service": TestParams["service"]}), - headers=Headers(fedHeader.headers) - ): - RO, Status = operations.post_search() - - assert Status == 200 - for server in RO: - loc = server["location"]["name"] - if server["status"] == 200: - assert server["results"] == GetResponse[loc]['results'] - # Test Federation with two nodes and local -----------------------------------------------------