Fix: Validate source_date in copy availability endpoint
Added validation to ensure source_date is within the allowed range (tomorrow to +30 days) for consistency with target_dates validation.
This commit is contained in:
parent
63cf46c230
commit
19c313767c
2 changed files with 17 additions and 0 deletions
|
|
@ -524,3 +524,17 @@ class TestCopyAvailability:
|
|||
assert response.status_code == 400
|
||||
assert "30" in response.json()["detail"]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_copy_validates_source_date(self, client_factory, admin_user):
|
||||
"""Cannot copy from a past source date."""
|
||||
async with client_factory.create(cookies=admin_user["cookies"]) as client:
|
||||
response = await client.post(
|
||||
"/api/admin/availability/copy",
|
||||
json={
|
||||
"source_date": str(date.today() - timedelta(days=1)), # Yesterday
|
||||
"target_dates": [str(in_days(1))],
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 400
|
||||
assert "past" in response.json()["detail"].lower()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue