mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
error on invalid role
This commit is contained in:
parent
0d352f3d8a
commit
11c425a7eb
@ -332,9 +332,15 @@ class FfmpegConfig(BaseModel):
|
||||
)
|
||||
|
||||
|
||||
class CameraRoleEnum(str, Enum):
|
||||
record = "record"
|
||||
rtmp = "rtmp"
|
||||
detect = "detect"
|
||||
|
||||
|
||||
class CameraInput(BaseModel):
|
||||
path: str = Field(title="Camera input path.")
|
||||
roles: List[str] = Field(title="Roles assigned to this input.")
|
||||
roles: List[CameraRoleEnum] = Field(title="Roles assigned to this input.")
|
||||
global_args: Union[str, List[str]] = Field(
|
||||
default_factory=list, title="FFmpeg global arguments."
|
||||
)
|
||||
|
@ -32,8 +32,8 @@ class TestConfig(unittest.TestCase):
|
||||
assert self.minimal == frigate_config.dict(exclude_unset=True)
|
||||
|
||||
runtime_config = frigate_config.runtime_config
|
||||
assert "coral" in runtime_config.detectors.keys()
|
||||
assert runtime_config.detectors["coral"].type == DetectorTypeEnum.edgetpu
|
||||
assert "cpu" in runtime_config.detectors.keys()
|
||||
assert runtime_config.detectors["cpu"].type == DetectorTypeEnum.cpu
|
||||
|
||||
def test_invalid_mqtt_config(self):
|
||||
config = {
|
||||
@ -692,6 +692,31 @@ class TestConfig(unittest.TestCase):
|
||||
runtime_config = frigate_config.runtime_config
|
||||
assert runtime_config.model.merged_labelmap[0] == "person"
|
||||
|
||||
def test_fails_on_invalid_role(self):
|
||||
|
||||
config = {
|
||||
"mqtt": {"host": "mqtt"},
|
||||
"cameras": {
|
||||
"back": {
|
||||
"ffmpeg": {
|
||||
"inputs": [
|
||||
{
|
||||
"path": "rtsp://10.0.0.1:554/video",
|
||||
"roles": ["detect", "clips"],
|
||||
},
|
||||
]
|
||||
},
|
||||
"detect": {
|
||||
"height": 1080,
|
||||
"width": 1920,
|
||||
"fps": 5,
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
self.assertRaises(ValidationError, lambda: FrigateConfig(**config))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(verbosity=2)
|
||||
|
Loading…
Reference in New Issue
Block a user