-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ticket 3] Create GET /reimbursements
Add GET /reimbursements endpoint. Tests through browser. Comments added for adding tests and organizing files & models in the future.
- Loading branch information
Sahar
committed
May 3, 2024
1 parent
bd96cbf
commit f6f9716
Showing
8 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" | ||
TODO | ||
- don't directly call DB | ||
- use API models instead of DB ones (see models.py) | ||
""" | ||
|
||
from fastapi import APIRouter | ||
from sqlmodel import select, Session | ||
|
||
from .db import engine | ||
from .models import Reimbursement | ||
|
||
api_router = APIRouter( | ||
prefix="/reimbursements", | ||
tags=["reimbursements"] | ||
) | ||
|
||
@api_router.get("/", response_model=list[Reimbursement]) | ||
async def get_reimbursements() -> list[Reimbursement]: | ||
with Session(engine) as session: | ||
return session.exec(select(Reimbursement)).all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
""" | ||
TODO: unit tests for api.py | ||
get_reimbursements | ||
- calls DB once | ||
- returns list of Reimbursements | ||
api_router variable: | ||
- prefix & tags correct? | ||
- GET for / path response is list of Reimbursements, no request params | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
""" | ||
TODO: unit tests for main.py | ||
- FastAPI gets called with lifespan argument | ||
- test for including api_router? | ||
- test that create_tables_with_data and delete_tables get called? | ||
""" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
TODO: | ||
implement tests | ||
once other tags/prefixes used, group endpoints for each tag under their own folders | ||
""" | ||
|
||
def test_get_reimbursements(): | ||
# TODO: returns the 3 reimbursements set up in db.py | ||
pass | ||
|
||
def test_get_reimbursements_no_records(): | ||
# TODO: (set up db for this test to not interfere with other tests somehow) returns empty list | ||
pass |