-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#375] Update case test for year filter
- Loading branch information
1 parent
6e5bbb5
commit 87679b4
Showing
2 changed files
with
52 additions
and
2 deletions.
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
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 |
---|---|---|
|
@@ -258,3 +258,50 @@ async def test_get_case_filtered_by_email( | |
"total": 2, | ||
"total_page": 1, | ||
} | ||
|
||
@pytest.mark.asyncio | ||
async def test_get_case_filtered_by_year( | ||
self, app: FastAPI, session: Session, client: AsyncClient | ||
) -> None: | ||
res = await client.get( | ||
app.url_path_for("case:get_all"), | ||
params={"year": "1992"}, | ||
headers={"Authorization": f"Bearer {admin_account.token}"}, | ||
) | ||
assert res.status_code == 404 | ||
res = await client.get( | ||
app.url_path_for("case:get_all"), | ||
params={"year": "2023"}, | ||
headers={"Authorization": f"Bearer {admin_account.token}"}, | ||
) | ||
assert res.status_code == 200 | ||
res = res.json() | ||
assert res == { | ||
"current": 1, | ||
"data": [ | ||
{ | ||
"id": 2, | ||
"name": "Bali Coffee Production (Private)", | ||
"country": "Bali", | ||
"focus_commodity": 1, | ||
"diversified_commodities_count": 1, | ||
"year": 2023, | ||
"created_at": res["data"][0]["created_at"], | ||
"created_by": "[email protected]", | ||
"tags": [], | ||
}, | ||
{ | ||
"id": 1, | ||
"name": "Bali Rice and Corn Production", | ||
"country": "Bali", | ||
"focus_commodity": 2, | ||
"diversified_commodities_count": 2, | ||
"year": 2023, | ||
"created_at": res["data"][1]["created_at"], | ||
"created_by": "[email protected]", | ||
"tags": [2, 1], | ||
}, | ||
], | ||
"total": 2, | ||
"total_page": 1, | ||
} |