1
0
Fork 0
forked from sr2/cloud-api

tests: body param generator

Issue: #24
This commit is contained in:
Chris Milne 2026-06-12 12:54:23 +01:00
parent 778f1dbece
commit fc9d7f8536
3 changed files with 76 additions and 151 deletions

View file

@ -5,8 +5,7 @@
import pytest
from httpx import AsyncClient
from .conftest import generate_query_and_status
from .conftest import generate_query_and_status, generate_body_and_status
pytestmark = [
pytest.mark.service_module,
@ -51,12 +50,7 @@ async def test_post_service_success(default_client: AsyncClient):
@pytest.mark.parametrize(
"body, expected_status",
[
({"name": "Test Service"}, 409),
({"name": 42}, 422),
({}, 422),
],
"body, expected_status", generate_body_and_status({"name": "str"})
)
@pytest.mark.anyio
async def test_post_service_status_checks(
@ -67,6 +61,13 @@ async def test_post_service_status_checks(
assert resp.status_code == expected_status
@pytest.mark.anyio
async def test_post_service_conflict(default_client: AsyncClient):
resp = await default_client.post("/service", json={"name": "Test Service"})
assert resp.status_code == 409
@pytest.mark.anyio
async def test_patch_service_success(default_client: AsyncClient):
resp = await default_client.patch("/service/key", json={"service_id": 1})
@ -82,12 +83,7 @@ async def test_patch_service_success(default_client: AsyncClient):
@pytest.mark.parametrize(
"body, expected_status",
[
({"service_id": 42}, 404),
({"service_id": "Test Service"}, 422),
({"service_id": ""}, 422),
({}, 422),
],
generate_body_and_status({"service_id": "int"}),
)
@pytest.mark.anyio
async def test_patch_services_status_checks(