Skip to content

Commit

Permalink
Update unit tests to match new endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
san99tiago committed Feb 26, 2024
1 parent 62f8e7f commit dcdef4f
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions tests/unit/lambdas/api/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,36 @@ def test_read_root():
assert response.json() == {"message": "Hello by Santi"}


def test_read_status():
response = client.get("/status")
def test_read_status_no_query():
response = client.get("/items/123")
assert response.status_code == 200
assert response.json() == {"status": "OK"}
assert response.json() == {"item_id": 123, "q": None}


def test_read_status_with_query():
response = client.get("/items/456?q=Santi")
assert response.status_code == 200
assert response.json() == {"item_id": 456, "q": "Santi"}


def test_update_item_success():
response = client.put(
"/items/789",
json={
"name": "test name",
"price": 99.9,
},
)
assert response.status_code == 200
assert response.json() == {"item_name": "test name", "item_id": 789}


def test_update_item_wrong_payload():
response = client.put(
"/items/789",
json={
"name": "test name",
"amount": 99.9, # Intentionally wrong key (not in model)
},
)
assert response.status_code == 422

0 comments on commit dcdef4f

Please sign in to comment.