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 1aa89b9 commit 5ffe0e6
Showing 1 changed file with 0 additions and 166 deletions.
166 changes: 0 additions & 166 deletions tests/test_uniform_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,179 +421,13 @@ 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"]
if server["status"] == 200:
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 -----------------------------------------------------


Expand Down

0 comments on commit 5ffe0e6

Please sign in to comment.