data nesting harmonized for 1 -> 1 and 1 -> n; pdf page extraction (1 -> n) working for non-batched usage
This commit is contained in:
parent
3172a00aaa
commit
77f23a2185
@ -45,11 +45,20 @@ def post_partial(url, input_data: Iterable[bytes], metadata):
|
||||
@pytest.mark.parametrize(
|
||||
"item_type",
|
||||
[
|
||||
"string",
|
||||
"image",
|
||||
# "string",
|
||||
# "image",
|
||||
"pdf"
|
||||
],
|
||||
)
|
||||
def test_sending_partial_request(url, input_data_items, metadata, operation, target_data_items, server_process):
|
||||
|
||||
print()
|
||||
print("exp")
|
||||
print(target_data_items)
|
||||
|
||||
output = list(post_partial(f"{url}/process", input_data_items, metadata))
|
||||
|
||||
print()
|
||||
print("out")
|
||||
print(output)
|
||||
assert output == target_data_items
|
||||
|
||||
10
test/fixtures/input.py
vendored
10
test/fixtures/input.py
vendored
@ -3,10 +3,10 @@ from functools import partial
|
||||
import numpy as np
|
||||
import pytest
|
||||
from PIL import Image
|
||||
from funcy import lmap, compose
|
||||
from funcy import lmap, compose, flatten
|
||||
|
||||
from pyinfra.rest import pack
|
||||
from pyinfra.utils.func import star
|
||||
from pyinfra.rest import pack, normalize_up
|
||||
from pyinfra.utils.func import star, lift
|
||||
from test.utils.image import image_to_bytes
|
||||
|
||||
|
||||
@ -32,8 +32,8 @@ def input_data_items(item_type, n_items, pdf):
|
||||
|
||||
@pytest.fixture
|
||||
def target_data_items(input_data_items, item_type, operation, metadata):
|
||||
op = compose(star(pack), partial(operation, metadata=metadata))
|
||||
expected = lmap(op, input_data_items)
|
||||
op = compose(lift(star(pack)), normalize_up, partial(operation, metadata=metadata))
|
||||
expected = list(flatten(map(op, input_data_items)))
|
||||
return expected
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user