mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-20 00:10:03 +02:00
tests: adds tests for restapi client logs
This commit is contained in:
parent
4d84c9778f
commit
1d8d17d715
@ -185,6 +185,7 @@ async def test_update_value(
|
|||||||
new_value: dict[str, Any],
|
new_value: dict[str, Any],
|
||||||
ok: bool,
|
ok: bool,
|
||||||
pydase_server: pydase.DataService,
|
pydase_server: pydase.DataService,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
async with aiohttp.ClientSession("http://localhost:9998") as session:
|
async with aiohttp.ClientSession("http://localhost:9998") as session:
|
||||||
resp = await session.put(
|
resp = await session.put(
|
||||||
@ -250,3 +251,43 @@ async def test_trigger_method(
|
|||||||
if resp.ok:
|
if resp.ok:
|
||||||
content = Deserializer.deserialize(json.loads(await resp.text()))
|
content = Deserializer.deserialize(json.loads(await resp.text()))
|
||||||
assert content == expected
|
assert content == expected
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"headers, log_id",
|
||||||
|
[
|
||||||
|
({}, "id=None"),
|
||||||
|
(
|
||||||
|
{
|
||||||
|
"X-Client-Id": "client-header",
|
||||||
|
},
|
||||||
|
"id=client-header",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{
|
||||||
|
"Remote-User": "Remote User",
|
||||||
|
},
|
||||||
|
"user=Remote User",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{
|
||||||
|
"X-Client-Id": "client-header",
|
||||||
|
"Remote-User": "Remote User",
|
||||||
|
},
|
||||||
|
"id=client-header",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
@pytest.mark.asyncio()
|
||||||
|
async def test_client_information_logging(
|
||||||
|
headers: dict[str, str],
|
||||||
|
log_id: str,
|
||||||
|
pydase_server: pydase.DataService,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
) -> None:
|
||||||
|
async with aiohttp.ClientSession("http://localhost:9998") as session:
|
||||||
|
await session.get(
|
||||||
|
"/api/v1/get_value?access_path=readonly_attr", headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
assert log_id in caplog.text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user