mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 01:05:20 +03:00
fix validator tests
This commit is contained in:
parent
c742c2703a
commit
34f8018a27
@ -408,28 +408,34 @@ class CameraGStreamerInput(CameraInput):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class CameraInputValidator:
|
def validate_roles(cls, v):
|
||||||
@validator("inputs")
|
roles = [role for i in v for role in i.roles]
|
||||||
def validate_roles(cls, v):
|
roles_set = set(roles)
|
||||||
roles = [role for i in v for role in i.roles]
|
|
||||||
roles_set = set(roles)
|
|
||||||
|
|
||||||
if len(roles) > len(roles_set):
|
if len(roles) > len(roles_set):
|
||||||
raise ValueError("Each input role may only be used once.")
|
raise ValueError("Each input role may only be used once.")
|
||||||
|
|
||||||
if not "detect" in roles:
|
if not "detect" in roles:
|
||||||
raise ValueError("The detect role is required.")
|
raise ValueError("The detect role is required.")
|
||||||
|
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
class CameraFfmpegConfig(FfmpegConfig, CameraInputValidator):
|
class CameraFfmpegConfig(FfmpegConfig):
|
||||||
inputs: List[CameraFFmpegInput] = Field(title="Camera FFMpeg inputs.")
|
inputs: List[CameraFFmpegInput] = Field(title="Camera FFMpeg inputs.")
|
||||||
|
|
||||||
|
@validator("inputs")
|
||||||
|
def validate_roles(cls, v):
|
||||||
|
return validate_roles(cls, v)
|
||||||
|
|
||||||
class CameraGStreamerConfig(GstreamerConfig, CameraInputValidator):
|
|
||||||
|
class CameraGStreamerConfig(GstreamerConfig):
|
||||||
inputs: List[CameraGStreamerInput] = Field(title="Camera GStreamer inputs.")
|
inputs: List[CameraGStreamerInput] = Field(title="Camera GStreamer inputs.")
|
||||||
|
|
||||||
|
@validator("inputs")
|
||||||
|
def validate_roles(cls, v):
|
||||||
|
return validate_roles(cls, v)
|
||||||
|
|
||||||
|
|
||||||
class SnapshotsConfig(FrigateBaseModel):
|
class SnapshotsConfig(FrigateBaseModel):
|
||||||
enabled: bool = Field(default=False, title="Snapshots enabled.")
|
enabled: bool = Field(default=False, title="Snapshots enabled.")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user