sbt-idp/tests/test_set_06_invoice_only.py

35 lines
1.2 KiB
Python
Raw Normal View History

2023-12-26 08:58:44 +00:00
import sys
sys.path.append(".")
from tests.utils import login, make_sbt_request, get_field
import os
import logging
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)
2024-05-03 01:51:05 +00:00
def check_invoice_data_2(document):
assert document["doc_type"] == "sbt_document"
assert get_field(document, "retailername") == "Starhub Shop"
assert get_field(document, "sold_to_party") is None
assert "2022-02-22" in get_field(document, "purchase_date")
2023-12-26 08:58:44 +00:00
def test_invoice_only():
invoice_files = [
"test_samples/sbt/20220303025923NHNE_20220222_Starhub_Order_Confirmation_by_Email.pdf"
]
imei_files = []
data = make_sbt_request(host=HOST, token=token, invoice_files=invoice_files, imei_files=imei_files, ensure_success=False)
2024-05-03 01:51:05 +00:00
data = data["data"]["data"]
assert data["total_pages"] == 1
assert data["ocr_num_pages"] == 1
assert data["status"] == 200
document = data["document"][0]
assert document["end_page"] == 1
assert document["start_page"] == 1
check_invoice_data_2(document)