renaming
This commit is contained in:
parent
940bc3a689
commit
bc0e9ed643
20
test/fixtures/server.py
vendored
20
test/fixtures/server.py
vendored
@ -12,7 +12,7 @@ from waitress import serve
|
||||
|
||||
from pyinfra.rest import wrap_operation
|
||||
from pyinfra.utils.buffer import bufferize
|
||||
from pyinfra.utils.func import lift, llift
|
||||
from pyinfra.utils.func import llift
|
||||
from test.server import set_up_processing_server
|
||||
from test.utils.image import image_to_bytes
|
||||
|
||||
@ -45,17 +45,16 @@ def server(processor_fn):
|
||||
|
||||
@pytest.fixture
|
||||
def processor_fn(operation, buffer_size, batched):
|
||||
|
||||
fn = wrap_operation(operation)
|
||||
operation = wrap_operation(operation)
|
||||
|
||||
if not batched:
|
||||
fn = llift(fn)
|
||||
operation = llift(operation)
|
||||
|
||||
return bufferize(fn, buffer_size=buffer_size, persist_fn=attrgetter("json"))
|
||||
return bufferize(operation, buffer_size=buffer_size, persist_fn=attrgetter("json"))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def operation(item_type):
|
||||
def operation(item_type, batched):
|
||||
def upper(string: bytes, metadata):
|
||||
return string.decode().upper().encode(), metadata
|
||||
|
||||
@ -68,14 +67,16 @@ def operation(item_type):
|
||||
yield page.get_pixmap().tobytes("png"), metadata
|
||||
|
||||
if item_type == "string":
|
||||
return upper
|
||||
operation = upper
|
||||
elif item_type == "image":
|
||||
return rotate
|
||||
operation = rotate
|
||||
elif item_type == "pdf":
|
||||
return stream_pages
|
||||
operation = stream_pages
|
||||
else:
|
||||
raise ValueError(f"No operation specified for item type {item_type}")
|
||||
|
||||
return operation
|
||||
|
||||
|
||||
@pytest.fixture(params=["string"])
|
||||
def item_type(request):
|
||||
@ -87,6 +88,7 @@ def batched(request):
|
||||
"""Controls, whether the buffer processor function of the webserver is applied to batches or single items."""
|
||||
return request.param
|
||||
|
||||
|
||||
@pytest.fixture(params=[1, 3, 7, 100])
|
||||
def buffer_size(request):
|
||||
return request.param
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user