added test for empty return-data operation, like classification

This commit is contained in:
Matthias Bisping 2022-05-23 09:58:43 +02:00
parent 02b0009219
commit 7ff466e0ea

View File

@ -1,5 +1,6 @@
import io
import socket
from collections import defaultdict
from itertools import repeat
from multiprocessing import Process
from typing import Generator
@ -72,7 +73,7 @@ def operation(core_operation):
@pytest.fixture
def core_operation(item_type, one_to_many):
def core_operation(item_type, one_to_many, analysis_task):
def upper(string: bytes):
return string.decode().upper().encode()
@ -84,6 +85,9 @@ def core_operation(item_type, one_to_many):
im = Image.open(io.BytesIO(im))
return image_to_bytes(im.rotate(90))
def classify(_: bytes):
return b""
def stream_pages(pdf: bytes):
for i, page in enumerate(fitz.open(stream=pdf)):
# yield page.get_pixmap().tobytes("png"), metadata
@ -92,15 +96,15 @@ def core_operation(item_type, one_to_many):
try:
d = {
False: {
"string": upper,
"image": rotate,
"string": defaultdict(lambda: upper),
"image": {False: rotate, True: classify},
},
True: {
"string": duplicate,
"pdf": stream_pages,
"string": defaultdict(lambda: duplicate),
"pdf": defaultdict(lambda: stream_pages),
},
}
return d[one_to_many][item_type]
return d[one_to_many][item_type][analysis_task]
except KeyError:
return Nothing
@ -115,6 +119,11 @@ def one_to_many(request):
return request.param
@pytest.fixture(params=[True, False])
def analysis_task(request):
return request.param
@pytest.fixture(params=[False, True])
def batched(request):
"""Controls, whether the buffer processor function of the webserver is applied to batches or single items."""