image-classification-service/test/unit_tests/process_wrapping_test.py
Julius Unverfehrt 561a7f527c Pull request #36: RED-4206 wrap queue callback in process to manage memory allocation with the operating system and force deallocation after processing.
Merge in RR/image-prediction from RED-4206-fix-unwanted-restart-bug to master

Squashed commit of the following:

commit 3dfe7b861816ef9019103e16a23efd97a08fb617
Author: Julius Unverfehrt <julius.unverfehrt@iqser.com>
Date:   Thu Sep 22 13:53:32 2022 +0200

    RED-4206 wrap queue callback in process to manage memory allocation with the operating system and force deallocation after processing.
2022-09-22 13:56:44 +02:00

25 lines
671 B
Python

import pytest
from image_prediction.utils.process_wrapping import wrap_in_process
@pytest.fixture
def process_fn_mock():
def _process(a: str, b: float, c: dict, d: list):
return a * 2, b + 3, c, d[0]
return _process
@pytest.fixture
def parameter():
return {"a": "A", "b": 0.42, "c": {"x": 1, "y": 2}, "d": [1, 2, 3]}
def test_process_wrapper_with_args(process_fn_mock, parameter):
assert process_fn_mock(*parameter.values()) == wrap_in_process(process_fn_mock)(*parameter.values())
def test_process_wrapper_with_kwargs(process_fn_mock, parameter):
assert process_fn_mock(**parameter) == wrap_in_process(process_fn_mock)(**parameter)