Skip to content

Commit

Permalink
Minor changes to backend testing
Browse files Browse the repository at this point in the history
Minor changes to tests to ensure commented tests work and run in reasonable amount of time.
  • Loading branch information
hyun-Davis committed Jun 4, 2024
1 parent 0d7d515 commit 56c7247
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions backend/tests/test_restful.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ def test_get_temp_data(client):
response = client.get(f'/temperature/{2021}')
assert response.status_code == 200

@pytest.mark.skip(reason= "This test takes a very long time. Uncomment when doing other tests.")
#@pytest.mark.skip(reason= "This test takes a very long time. Uncomment when doing other tests.")
def test_valid_predictions(client):

test_directory = os.getcwd()
os.chdir('./app')

valid_birds = [
"warbler",
"eagle",
Expand All @@ -83,6 +86,8 @@ def test_valid_predictions(client):
'ssp370',
'ssp585'
]
'''
uncomment to test every possible SSP and every possible year.
for ssp in ssps:
Expand All @@ -98,7 +103,18 @@ def test_valid_predictions(client):
response_body = read_response_body(response)
assert response.status_code == 200
assert response_body['resFormat'] == "PNG"
assert response_body['resFormat'] == "PNG"'''
payload = {
"bird": "warbler",
"year": 2025,
"emissions": 'ssp245',
}

response = client.put('/prediction', json= payload)
assert response.status_code == 200

os.chdir(test_directory)


def test_invalid_predictions(client):

Expand Down Expand Up @@ -146,7 +162,7 @@ def test_get_sdm_data(client):

assert client.get(f'/bird-info/bad_get').status_code == 404

@pytest.mark.skip(reason= "This test takes a very long time. Uncomment when doing other tests.")
#@pytest.mark.skip(reason= "This test takes a very long time. Uncomment when doing other tests.")
def test_get_bird_ids(client):

# Test if the backend can retreive bird ids for all valid birds.
Expand All @@ -167,10 +183,9 @@ def test_get_bird_ids(client):
assert ids_response.status_code == 200

ids_content = read_response_body(ids_response)
for id in ids_content:
traj_resp = client.get(f'/get_trajectory_data?bird={bird}&birdID={id}')
traj_resp = client.get(f'/get_trajectory_data?bird={bird}&birdID={ids_content[0]}')

assert traj_resp.status_code == 200
assert traj_resp.status_code == 200

# Assert that for each bird, a bad response is handled properly.
assert client.get(f'/get_trajectory_data?bird={bird}&birdID=BAD_ID').status_code == 404
Expand Down

0 comments on commit 56c7247

Please sign in to comment.