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
|
2024-06-28 06:44:30 +00:00
|
|
|
assert "2024-02-22" in get_field(document, "purchase_date")
|
2024-05-03 01:51:05 +00:00
|
|
|
|
|
|
|
|
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)
|