diff --git a/test_samples/test_21.json b/test_samples/test_21.json new file mode 100644 index 0000000..9c9caeb --- /dev/null +++ b/test_samples/test_21.json @@ -0,0 +1,27 @@ +{ + "content": [ + { + "label": "retailername", + "value": "Best Denki" + }, + { + "label": "sold_to_party", + "value": null + }, + { + "label": "purchase_date", + "value": [ + "2022-02-18" + ] + }, + { + "label": "imei_number", + "value": [ + "357822611219904" + ] + } + ], + "doc_type": "sbt_document", + "end_page": 2, + "start_page": 1 +} \ No newline at end of file diff --git a/test_samples/test_22.json b/test_samples/test_22.json new file mode 100644 index 0000000..599c50a --- /dev/null +++ b/test_samples/test_22.json @@ -0,0 +1,28 @@ +{ + "content": [ + { + "label": "retailername", + "value": "Best Denki" + }, + { + "label": "sold_to_party", + "value": null + }, + { + "label": "purchase_date", + "value": [ + "2022-02-18" + ] + }, + { + "label": "imei_number", + "value": [ + "357822611219904", + "RFAW2022FED" + ] + } + ], + "doc_type": "sbt_document", + "end_page": 3, + "start_page": 1 +} \ No newline at end of file diff --git a/test_samples/test_23.json b/test_samples/test_23.json new file mode 100644 index 0000000..9735e3b --- /dev/null +++ b/test_samples/test_23.json @@ -0,0 +1,29 @@ +{ + "content": [ + { + "label": "retailername", + "value": "Best Denki" + }, + { + "label": "sold_to_party", + "value": null + }, + { + "label": "purchase_date", + "value": [ + "2022-02-18" + ] + }, + { + "label": "imei_number", + "value": [ + "357822611219904", + "RFAW2022FED", + "5AWH14MT400396N" + ] + } + ], + "doc_type": "sbt_document", + "end_page": 4, + "start_page": 1 +} \ No newline at end of file diff --git a/test_samples/test_24.json b/test_samples/test_24.json new file mode 100644 index 0000000..84f155c --- /dev/null +++ b/test_samples/test_24.json @@ -0,0 +1,30 @@ +{ + "content": [ + { + "label": "retailername", + "value": "Best Denki" + }, + { + "label": "sold_to_party", + "value": null + }, + { + "label": "purchase_date", + "value": [ + "2022-02-18" + ] + }, + { + "label": "imei_number", + "value": [ + "357822611219904", + "RFAW2022FED", + "5AWH14MT400396N", + "0HU33NIW200044K" + ] + } + ], + "doc_type": "sbt_document", + "end_page": 5, + "start_page": 1 +} \ No newline at end of file diff --git a/test_samples/test_25.json b/test_samples/test_25.json new file mode 100644 index 0000000..92a2439 --- /dev/null +++ b/test_samples/test_25.json @@ -0,0 +1,31 @@ +{ + "content": [ + { + "label": "retailername", + "value": "Best Denki" + }, + { + "label": "sold_to_party", + "value": null + }, + { + "label": "purchase_date", + "value": [ + "2022-02-18" + ] + }, + { + "label": "imei_number", + "value": [ + "357822611219904", + "RFAW2022FED", + "5AWH14MT400396N", + "0HU33NIW200044K", + "0GJG4DBW200318X" + ] + } + ], + "doc_type": "sbt_document", + "end_page": 6, + "start_page": 1 +} \ No newline at end of file diff --git a/tests/test_set_21_to_25.py b/tests/test_set_21_to_25.py new file mode 100644 index 0000000..25e08c9 --- /dev/null +++ b/tests/test_set_21_to_25.py @@ -0,0 +1,97 @@ +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_1_imei(): + invoice_files = [ + "test_samples/test_07/invoice_jpg.jpg", + ] + imei_files = [ + "test_samples/test_07/imei_valid_1.jpg", + ] + data = make_sbt_request(host=HOST, token=token, invoice_files=invoice_files, imei_files=imei_files, ensure_success=False) + document = data["data"]["data"]["document"][0] + gt = json.load(open("test_samples/test_21.json", "r")) + diff = deepdiff.DeepDiff(document, gt) + + assert diff == {}, f"Different result! GT: {gt}; RESULT: {document}" + + +def test_1_invoice_2_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", + ] + data = make_sbt_request(host=HOST, token=token, invoice_files=invoice_files, imei_files=imei_files, ensure_success=False) + document = data["data"]["data"]["document"][0] + gt = json.load(open("test_samples/test_22.json", "r")) + diff = deepdiff.DeepDiff(document, gt) + + assert diff == {}, f"Different result! GT: {gt}; RESULT: {document}" + + +def test_1_invoice_3_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", + ] + data = make_sbt_request(host=HOST, token=token, invoice_files=invoice_files, imei_files=imei_files, ensure_success=False) + document = data["data"]["data"]["document"][0] + gt = json.load(open("test_samples/test_23.json", "r")) + diff = deepdiff.DeepDiff(document, gt) + + assert diff == {}, f"Different result! GT: {gt}; RESULT: {document}" + + +def test_1_invoice_4_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", + ] + data = make_sbt_request(host=HOST, token=token, invoice_files=invoice_files, imei_files=imei_files, ensure_success=False) + document = data["data"]["data"]["document"][0] + gt = json.load(open("test_samples/test_24.json", "r")) + diff = deepdiff.DeepDiff(document, gt) + + assert diff == {}, f"Different result! GT: {gt}; RESULT: {document}" + + +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) + document = data["data"]["data"]["document"][0] + gt = json.load(open("test_samples/test_25.json", "r")) + diff = deepdiff.DeepDiff(document, gt) + + assert diff == {}, f"Different result! GT: {gt}; RESULT: {document}"