import sys sys.path.append(".") from tests.utils import login, make_sbt_request, get_field import os import logging import json import deepdiff HOST = os.environ.get("IDP_HOST", "XXXXXXXXXXXXXXXXXXXXX") USERNAME = os.environ.get("IDP_USERNAME", "XXXXXXXXXXXXXXXXXXXXX") PASSWORD = os.environ.get("IDP_PASSWORD", "XXXXXXXXXXXXXXXXXXXXX") token = login(HOST, USERNAME, PASSWORD) def test_1_invoice_6_imei(): invoice_files = [ "test_samples/test_07/invoice_jpg.jpg", ] imei_files = [ "test_samples/test_07/imei_valid_1.jpg", "test_samples/test_07/imei_valid_2.jpg", "test_samples/test_07/imei_valid_3.jpg", "test_samples/test_07/imei_valid_4.jpg", "test_samples/test_07/imei_valid_5.jpg", "test_samples/test_07/imei_valid_6.jpg", ] data = make_sbt_request(host=HOST, token=token, invoice_files=invoice_files, imei_files=imei_files, ensure_success=False) assert "Limit reached. Number of imei_file limit at 5" in str(data["data"]) def test_1_invoice_5_imei(): invoice_files = [ "test_samples/test_07/invoice_jpg.jpg", ] imei_files = [ "test_samples/test_07/imei_valid_1.jpg", "test_samples/test_07/imei_valid_2.jpg", "test_samples/test_07/imei_valid_3.jpg", "test_samples/test_07/imei_valid_4.jpg", "test_samples/test_07/imei_valid_5.jpg", ] data = make_sbt_request(host=HOST, token=token, invoice_files=invoice_files, imei_files=imei_files, ensure_success=False) data = data["data"]["data"] assert data["total_pages"] == 6 assert data["ocr_num_pages"] == 6 assert data["status"] == 200 document = data["document"][0] assert document["end_page"] == 6 assert document["start_page"] == 1 gt = { "content": [ { "label": "retailername", "value": "Best Denki" }, { "label": "sold_to_party", "value": None }, { "label": "purchase_date", "value": [ "2022-02-18" ] }, { "label": "imei_number", "value": [ "357822611219904", "RFAW2022FED", "5AWH14MT400396N", "0HU33NIW200044K", "0GJG4DBW200318X" ] }, { "label": "invoice_no", "value": None } ], "doc_type": "sbt_document", "end_page": 6, "start_page": 1 } diff = deepdiff.DeepDiff(document, gt) assert diff == {}, f"Different result! GT: {gt}; RESULT: {document}"