Skip to content

Commit

Permalink
rename from max-ratings POST to disability-max-ratings
Browse files Browse the repository at this point in the history
  • Loading branch information
gabezurita committed Dec 10, 2024
1 parent 69ce261 commit 7536a34
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ uvicorn api:app --port 8130 --reload

## Testing it all together

Run the Python webserver (uvicorn command above). Now you should be able to make a post request to the `/max-ratings/`
Run the Python webserver (uvicorn command above). Now you should be able to make a post request to the `/disability-max-ratings/`
endpoint with a request body of the format:

```
Expand Down
9 changes: 9 additions & 0 deletions src/python_src/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import uvicorn
from fastapi import FastAPI, HTTPException
from fastapi.responses import RedirectResponse
from pydantic_models import (
MaxRatingsForClaimForIncreaseRequest,
MaxRatingsForClaimForIncreaseResponse,
Expand Down Expand Up @@ -36,6 +37,14 @@ def get_health_status() -> dict[str, str]:


@app.post('/max-ratings')
def redirect_max_ratings() -> RedirectResponse:
"""
Redirects the old /max-ratings endpoint to the new /disability-max-ratings endpoint.
"""
return RedirectResponse(url='/disability-max-ratings')


@app.post('/disability-max-ratings')
def get_max_ratings(
claim_for_increase: MaxRatingsForClaimForIncreaseRequest,
) -> MaxRatingsForClaimForIncreaseResponse:
Expand Down
13 changes: 12 additions & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
from fastapi.testclient import TestClient

MAX_RATING = '/max-ratings'
MAX_RATING = '/disability-max-ratings'
LEGACY_ENDPOINT = '/max-ratings'

TINNITUS = {'diagnostic_code': 6260, 'max_rating': 10}
TUBERCULOSIS = {'diagnostic_code': 7710, 'max_rating': 100}
NOT_RATED = {'diagnostic_code': 9999}


def test_redirect_from_legacy_endpoint(client: TestClient) -> None:
"""Test that the legacy endpoint redirects to the new endpoint"""
json_post_dict = {'diagnostic_codes': [TINNITUS['diagnostic_code']]}

response = client.post(LEGACY_ENDPOINT, json=json_post_dict, allow_redirects=False)

assert response.status_code == 307 # Temporary Redirect
assert response.headers['location'] == MAX_RATING


def test_max_rating_with_no_dc(client: TestClient):
json_post_dict = {'diagnostic_codes': []}

Expand Down

0 comments on commit 7536a34

Please sign in to comment.