mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-26 19:05:13 +00:00
refactor(api): admit download job create and retry through one job_admission step
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
"""Test helper for the parameter check of download job admission."""
|
||||
|
||||
from typing import Any
|
||||
|
||||
from unshackle.core.api.errors import APIError
|
||||
from unshackle.core.api.job_admission import check_parameters, check_plan
|
||||
from unshackle.core.remote_protocol import APIErrorCode
|
||||
|
||||
|
||||
def refusal(data: dict[str, Any]) -> str | None:
|
||||
"""The message of the INVALID_PARAMETERS refusal that the parameter and plan checks give ``data``, else None."""
|
||||
try:
|
||||
check_plan(check_parameters(data))
|
||||
except APIError as e:
|
||||
assert e.error_code is APIErrorCode.INVALID_PARAMETERS
|
||||
return e.message
|
||||
return None
|
||||
Reference in New Issue
Block a user