From e58b9ad8b2b2e10af7cb660527d703d6043d72af Mon Sep 17 00:00:00 2001 From: Olivier Le Thanh Duong Date: Mon, 29 Apr 2024 17:42:46 +0200 Subject: [PATCH] add unit test for system usage --- tests/supervisor/test_views.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/supervisor/test_views.py b/tests/supervisor/test_views.py index 49a6fa91e..73bcfec45 100644 --- a/tests/supervisor/test_views.py +++ b/tests/supervisor/test_views.py @@ -24,3 +24,16 @@ async def test_allocation_fails_on_invalid_item_hash(aiohttp_client): "type": "value_error.unknownhash", }, ] + + +@pytest.mark.asyncio +async def test_system_usage(aiohttp_client): + """Test that the allocation endpoint fails when an invalid item_hash is provided.""" + client = await aiohttp_client(app) + settings.ALLOCATION_TOKEN_HASH = "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" # = "test" + response: web.Response = await client.get("/about/usage/system") + assert response.status == 200 + # check if it is valid json + resp = await response.json() + assert "cpu" in resp + assert resp["cpu"]["count"] > 0