Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
test: Adds unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
frgfm committed Dec 4, 2023
1 parent 9a84d69 commit 5827f25
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/tests/endpoints/test_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,31 @@ async def test_reorder_repo_guidelines(
assert [entry["order"] for entry in response.json()] == [
payload["guideline_ids"].index(entry["id"]) for entry in GUIDELINE_TABLE
]


@pytest.mark.parametrize(
("user_idx", "repo_id", "status_code", "status_detail"),
[
(None, 12345, 401, "Not authenticated"),
(0, 100, 404, "Not Found"),
(0, 249513553, 200, None),
(1, 249513553, 200, None),
],
)
@pytest.mark.asyncio()
async def test_add_repo_to_waitlist(
async_client: AsyncClient,
guideline_session: AsyncSession,
user_idx: Union[int, None],
repo_id: int,
status_code: int,
status_detail: Union[str, None],
):
auth = None
if isinstance(user_idx, int):
auth = await pytest.get_token(USER_TABLE[user_idx]["id"], USER_TABLE[user_idx]["scope"].split())

response = await async_client.post(f"/repos/{repo_id}/waitlist", headers=auth)
assert response.status_code == status_code, print(response.json())
if isinstance(status_detail, str):
assert response.json()["detail"] == status_detail

0 comments on commit 5827f25

Please sign in to comment.