pierrejeambrun commented on code in PR #46986:
URL: https://github.com/apache/airflow/pull/46986#discussion_r1967599653
##########
tests/api_fastapi/core_api/routes/public/test_pools.py:
##########
@@ -143,83 +143,57 @@ class TestPatchPool(TestPoolsEndpoint):
(
Pool.DEFAULT_POOL_NAME,
{},
- {},
+ {"pool": Pool.DEFAULT_POOL_NAME},
400,
{"detail": "Only slots and included_deferred can be modified
on Default Pool"},
),
(
Pool.DEFAULT_POOL_NAME,
{"update_mask": ["description"]},
- {},
+ {"pool": Pool.DEFAULT_POOL_NAME},
400,
{"detail": "Only slots and included_deferred can be modified
on Default Pool"},
),
(
"unknown_pool",
{},
- {},
+ {"pool": "unknown_pool"},
404,
{"detail": "The Pool with name: `unknown_pool` was not found"},
),
(
POOL1_NAME,
{},
- {},
+ {"pool": POOL1_NAME},
422,
{
"detail": [
{
- "input": {},
- "loc": ["pool"],
- "msg": "Field required",
- "type": "missing",
- },
- {
- "input": {},
+ "input": {"pool": POOL1_NAME},
"loc": ["slots"],
"msg": "Field required",
"type": "missing",
},
{
- "input": {},
+ "input": {"pool": POOL1_NAME},
"loc": ["description"],
"msg": "Field required",
"type": "missing",
},
{
- "input": {},
+ "input": {"pool": POOL1_NAME},
"loc": ["include_deferred"],
"msg": "Field required",
"type": "missing",
},
],
},
),
- # Success
- # Partial body
- (
- POOL1_NAME,
- {"update_mask": ["name"]},
- {"slots": 150, "name": "pool_1_updated"},
- 200,
- {
- "deferred_slots": 0,
- "description": None,
- "include_deferred": True,
- "name": "pool_1_updated",
- "occupied_slots": 0,
- "open_slots": 3,
- "queued_slots": 0,
- "running_slots": 0,
- "scheduled_slots": 0,
- "slots": 3,
- },
- ),
# Partial body on default_pool
(
Pool.DEFAULT_POOL_NAME,
{"update_mask": ["slots"]},
- {"slots": 150},
+ {"pool": Pool.DEFAULT_POOL_NAME, "slots": 150},
Review Comment:
Or we could omit the pool name.
##########
tests/api_fastapi/core_api/routes/public/test_pools.py:
##########
@@ -143,83 +143,57 @@ class TestPatchPool(TestPoolsEndpoint):
(
Pool.DEFAULT_POOL_NAME,
{},
- {},
+ {"pool": Pool.DEFAULT_POOL_NAME},
Review Comment:
Should simply omit too I think.
##########
airflow/api_fastapi/core_api/routes/public/pools.py:
##########
@@ -134,6 +134,11 @@ def patch_pool(
update_mask: list[str] | None = Query(None),
) -> PoolResponse:
"""Update a Pool."""
+ if patch_body.name != pool_name:
+ raise HTTPException(
+ status.HTTP_400_BAD_REQUEST,
+ "Invalid body, pool name from request body doesn't match uri
parameter",
+ )
Review Comment:
We need a test case for that I think.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]