diff --git a/frigate/test/test_object_detector.py b/frigate/test/test_object_detector.py index e50723a0fa..1216c49d76 100644 --- a/frigate/test/test_object_detector.py +++ b/frigate/test/test_object_detector.py @@ -3,7 +3,7 @@ from unittest.mock import MagicMock, Mock, patch import numpy as np import zmq -from pydantic import parse_obj_as +from pydantic import TypeAdapter import frigate.detectors as detectors import frigate.object_detection.base @@ -20,8 +20,8 @@ class TestLocalObjectDetector(unittest.TestCase): "frigate.detectors.api_types", {det_type: Mock() for det_type in DetectorTypeEnum}, ): - test_cfg = parse_obj_as( - DetectorConfig, ({"type": det_type, "model": {}}) + test_cfg = TypeAdapter(DetectorConfig).validate_python( + {"type": det_type, "model": {}} ) test_cfg.model.path = "/test/modelpath" test_obj = frigate.object_detection.base.LocalObjectDetector( @@ -45,7 +45,9 @@ class TestLocalObjectDetector(unittest.TestCase): TEST_DATA = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] TEST_DETECT_RESULT = np.ndarray([1, 2, 4, 8, 16, 32]) test_obj_detect = frigate.object_detection.base.LocalObjectDetector( - detector_config=parse_obj_as(DetectorConfig, {"type": "cpu", "model": {}}) + detector_config=TypeAdapter(DetectorConfig).validate_python( + {"type": "cpu", "model": {}} + ) ) mock_det_api = mock_cputfl.return_value @@ -68,7 +70,9 @@ class TestLocalObjectDetector(unittest.TestCase): TEST_DATA = np.zeros((1, 32, 32, 3), np.uint8) TEST_DETECT_RESULT = np.ndarray([1, 2, 4, 8, 16, 32]) - test_cfg = parse_obj_as(DetectorConfig, {"type": "cpu", "model": {}}) + test_cfg = TypeAdapter(DetectorConfig).validate_python( + {"type": "cpu", "model": {}} + ) test_cfg.model.input_tensor = InputTensorEnum.nchw test_obj_detect = frigate.object_detection.base.LocalObjectDetector( @@ -117,7 +121,9 @@ class TestLocalObjectDetector(unittest.TestCase): 4: "label-5", } - test_cfg = parse_obj_as(DetectorConfig, {"type": "cpu", "model": {}}) + test_cfg = TypeAdapter(DetectorConfig).validate_python( + {"type": "cpu", "model": {}} + ) test_cfg.model = ModelConfig() test_obj_detect = frigate.object_detection.base.LocalObjectDetector( detector_config=test_cfg,