-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
65 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
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,6 @@ | ||
# Permissions | ||
|
||
::: harborapi.client.HarborAsyncClient | ||
options: | ||
members: | ||
- get_permissions |
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
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,32 @@ | ||
from __future__ import annotations | ||
|
||
import pytest | ||
from hypothesis import HealthCheck | ||
from hypothesis import given | ||
from hypothesis import settings | ||
from hypothesis import strategies as st | ||
from pytest_httpserver import HTTPServer | ||
|
||
from harborapi.client import HarborAsyncClient | ||
from harborapi.models.models import Permissions | ||
|
||
|
||
@pytest.mark.asyncio | ||
@given(st.builds(Permissions)) | ||
@settings(suppress_health_check=[HealthCheck.function_scoped_fixture]) | ||
async def test_get_permissions( | ||
async_client: HarborAsyncClient, | ||
httpserver: HTTPServer, | ||
permissions: Permissions, | ||
): | ||
httpserver.expect_oneshot_request( | ||
"/api/v2.0/permissions", | ||
method="GET", | ||
).respond_with_json( | ||
permissions.model_dump(mode="json"), | ||
headers={"Content-Type": "application/json"}, | ||
) | ||
async_client.url = httpserver.url_for("/api/v2.0") | ||
|
||
resp = await async_client.get_permissions() | ||
assert resp == permissions |