Skip to content

Commit

Permalink
Merge pull request #1891 from fractal-analytics-platform/1882-add-val…
Browse files Browse the repository at this point in the history
…idation-of-task-collection-payload

Test validation of task collection payload
  • Loading branch information
tcompa authored Oct 10, 2024
2 parents e937ff8 + 9433473 commit 993df2f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ into pre-release sections below.
* Do not process task sources in task/task-group CRUD operations (\#1861).
* Do not process task owners in task/task-group CRUD operations (\#1861).
* Expand use and validators for `TaskGroupCreateV2` schema (\#1861).
* Forbid extras in `TaskCollectPipV2` (\#1891).
* Database:
* Add `taskgroupv2_id` foreign key to `CollectionStateV2` (\#1867).
* Make `TaskV2.source` nullable and drop its uniqueness constraint (\#1861).
Expand Down
3 changes: 2 additions & 1 deletion fractal_server/app/schemas/v2/task_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Optional

from pydantic import BaseModel
from pydantic import Extra
from pydantic import root_validator
from pydantic import validator

Expand All @@ -24,7 +25,7 @@ class CollectionStatusV2(str, Enum):
OK = "OK"


class TaskCollectPipV2(BaseModel):
class TaskCollectPipV2(BaseModel, extra=Extra.forbid):
"""
TaskCollectPipV2 class
Expand Down
2 changes: 0 additions & 2 deletions tests/v2/03_api/test_api_task_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ async def test_task_collection_custom(
source="source1",
package_root=None,
package_name=package_name,
version=None,
)

# Fail because no package is installed in sys.executable
Expand Down Expand Up @@ -442,7 +441,6 @@ async def test_task_collection_custom(
source="source3",
package_root=package_root,
package_name=None,
version=None,
)
res = await client.post(
f"{PREFIX}/collect/custom/", json=payload_root.dict()
Expand Down
7 changes: 5 additions & 2 deletions tests/v2/03_api/test_api_task_collection_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,12 @@ async def test_task_collection_ssh_from_wheel(
f"{PREFIX}/collect/pip/",
json=dict(
package=remote_wheel_path,
version="1.2.3",
package_version="1.2.3",
python_version=current_py_version,
),
)
assert res.status_code == 422
debug(res.json())
error_msg = (
"Cannot provide package version when package " "is a wheel file."
)
assert error_msg in str(res.json()["detail"])

0 comments on commit 993df2f

Please sign in to comment.