Skip to content

Commit

Permalink
Update endpoints wrt the latest frontend requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinika committed Apr 22, 2024
1 parent 02c92a8 commit 400aabd
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
5 changes: 2 additions & 3 deletions expenses_server/tests/test_create_expense.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ def test_virtual_lab_created(test_client: TestClient) -> None:
"category_name": "groceries",
"account_id": 1,
}
response = test_client.post("/expenses", json=payload)
response = test_client.post("/api/expenses", json=payload)
assert response.status_code == 200
data = response.json()
assert data["id"] is not None
assert data["amount"] == 10.0
assert data["currency"] == "CHF"
assert data["description"] == "Migros"
assert data["category"]["id"] == 1
assert data["category"]["name"] == "groceries"
assert data["category"] == "groceries"
assert data["account"]["id"] == 1
assert data["account"]["name"] == "Wise David"
4 changes: 2 additions & 2 deletions expenses_server/tests/test_delete_expense.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
def test_delete_expenses(test_expenses: tuple[TestClient, list[dict]]) -> None:
client, mock_expenses = test_expenses
expense_id = mock_expenses[0]["id"]
response = client.delete(f"/expenses/{expense_id}")
response = client.delete(f"/api/expenses/{expense_id}")
assert response.status_code == HTTPStatus.OK
assert response.json() == mock_expenses[0]

get_deleted_expense = client.get(f"/expenses/{expense_id}")
get_deleted_expense = client.get(f"/api/expenses/{expense_id}")
assert get_deleted_expense.status_code == HTTPStatus.NOT_FOUND
2 changes: 1 addition & 1 deletion expenses_server/tests/test_get_all_expenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def test_get_all_expenses(test_expenses: tuple[TestClient, list[ExpenseDTO]]) -> None:
client, mock_expenses = test_expenses
response = client.get("/expenses")
response = client.get("/api/expenses")
assert response.status_code == 200
expenses = cast(list[ExpenseDTO], response.json())
assert len(expenses) >= len(mock_expenses)
Expand Down
2 changes: 1 addition & 1 deletion expenses_server/tests/test_get_expense.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
def test_get_expense(test_expenses: tuple[TestClient, list[dict]]) -> None:
client, mock_expenses = test_expenses
expense_id = mock_expenses[0]["id"]
response = client.get(f"/expenses/{expense_id}")
response = client.get(f"/api/expenses/{expense_id}")
assert response.status_code == 200
assert response.json() == mock_expenses[0]
4 changes: 3 additions & 1 deletion expenses_server/tests/test_update_expense.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def test_update_expense(test_expenses: tuple[TestClient, list[dict]]) -> None:
expected_response = copy.deepcopy(expense_before_update)
expected_response.update(payload)

response = client.patch(f"/expenses/{expense_before_update["id"]}", json=payload)
response = client.patch(
f"/api/expenses/{expense_before_update["id"]}", json=payload
)
assert response.status_code == 200
actual_response = response.json()
assert actual_response == expected_response
2 changes: 1 addition & 1 deletion expenses_server/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ def create_mock_expense(
**extra,
}
)
response = client.post("/expenses", json=payload)
response = client.post("/api/expenses", json=payload)
assert response.status_code == 200
return cast(dict, response.json())

0 comments on commit 400aabd

Please sign in to comment.