diff --git a/test/conftest.py b/test/conftest.py new file mode 100644 index 0000000..ce65f3d --- /dev/null +++ b/test/conftest.py @@ -0,0 +1,55 @@ +import pytest + + +@pytest.fixture +def predictions(): + return [ + { + "class": "signature", + "probabilities": { + "signature": 1.0, + "logo": 9.150285377746546e-19, + "other": 4.374506412383356e-19, + "formula": 3.582569597002796e-24, + }, + } + ] + + +@pytest.fixture +def metadata(): + return [ + { + "page_height": 612.0, + "page_width": 792.0, + "height": 61.049999999999955, + "width": 139.35000000000002, + "page_idx": 8, + "x1": 63.5, + "x2": 202.85000000000002, + "y1": 472.0, + "y2": 533.05, + } + ] + + +@pytest.fixture +def response(): + return [ + { + "classification": { + "label": "signature", + "probabilities": {"formula": 0.0, "logo": 0.0, "other": 0.0, "signature": 1.0}, + }, + "filters": { + "allPassed": True, + "geometry": { + "imageFormat": {"quotient": 2.282555282555285, "tooTall": False, "tooWide": False}, + "imageSize": {"quotient": 0.13248234868245012, "tooLarge": False, "tooSmall": False}, + }, + "probability": {"unconfident": False}, + }, + "geometry": {"height": 61.049999999999955, "width": 139.35000000000002}, + "position": {"pageNumber": 9, "x1": 63.5, "x2": 202.85000000000002, "y1": 472.0, "y2": 533.05}, + } + ] diff --git a/test/test_response.py b/test/test_response.py new file mode 100644 index 0000000..696c92b --- /dev/null +++ b/test/test_response.py @@ -0,0 +1,5 @@ +from image_prediction.response import build_response + + +def test_build_response_returns_valid_response(predictions, metadata, response): + assert build_response(predictions, metadata) == response