Add tests 21-25

This commit is contained in:
Viet Anh Nguyen 2023-12-26 16:45:01 +07:00
parent 9ae369d7c6
commit 1d030c48cd
6 changed files with 242 additions and 0 deletions

27
test_samples/test_21.json Normal file
View File

@ -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
}

28
test_samples/test_22.json Normal file
View File

@ -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
}

29
test_samples/test_23.json Normal file
View File

@ -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
}

30
test_samples/test_24.json Normal file
View File

@ -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
}

31
test_samples/test_25.json Normal file
View File

@ -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
}

View File

@ -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}"