diff --git a/mindee/product/barcode_reader/barcode_reader_v1_document.py b/mindee/product/barcode_reader/barcode_reader_v1_document.py index b5e7e777..92e857e7 100644 --- a/mindee/product/barcode_reader/barcode_reader_v1_document.py +++ b/mindee/product/barcode_reader/barcode_reader_v1_document.py @@ -39,5 +39,6 @@ def __str__(self) -> str: codes_2d = f"\n { ' ' * 13 }".join( [str(item) for item in self.codes_2d], ) - - return clean_out_string(f":Barcodes 1D: {codes_1d}\n" f":Barcodes 2D: {codes_2d}\n") + return clean_out_string( + f":Barcodes 1D: {codes_1d}\n" f":Barcodes 2D: {codes_2d}\n" + ) diff --git a/mindee/product/cropper/cropper_v1_document.py b/mindee/product/cropper/cropper_v1_document.py index 58f17690..b6bab215 100644 --- a/mindee/product/cropper/cropper_v1_document.py +++ b/mindee/product/cropper/cropper_v1_document.py @@ -4,6 +4,5 @@ class CropperV1Document(Prediction): """Document data for Cropper, API version 1.""" - def __str__(self) -> str: return "" diff --git a/mindee/product/eu/license_plate/license_plate_v1_document.py b/mindee/product/eu/license_plate/license_plate_v1_document.py index 07e3c9d2..4145fe2b 100644 --- a/mindee/product/eu/license_plate/license_plate_v1_document.py +++ b/mindee/product/eu/license_plate/license_plate_v1_document.py @@ -30,5 +30,4 @@ def __str__(self) -> str: license_plates = f"\n { ' ' * 16 }".join( [str(item) for item in self.license_plates], ) - return clean_out_string(f":License Plates: {license_plates}\n") diff --git a/mindee/product/financial_document/financial_document_v1_document.py b/mindee/product/financial_document/financial_document_v1_document.py index f784dafa..ad6be90d 100644 --- a/mindee/product/financial_document/financial_document_v1_document.py +++ b/mindee/product/financial_document/financial_document_v1_document.py @@ -12,7 +12,7 @@ Taxes, ) from mindee.product.financial_document.financial_document_v1_line_item import ( - FinancialDocumentV1LineItem, + FinancialDocumentV1LineItem, ) @@ -213,7 +213,6 @@ def __str__(self) -> str: supplier_payment_details = f"\n { ' ' * 26 }".join( [str(item) for item in self.supplier_payment_details], ) - return clean_out_string( f":Locale: {self.locale}\n" f":Invoice Number: {self.invoice_number}\n" diff --git a/mindee/product/fr/bank_account_details/bank_account_details_v1_document.py b/mindee/product/fr/bank_account_details/bank_account_details_v1_document.py index 8a0ecf58..924a4303 100644 --- a/mindee/product/fr/bank_account_details/bank_account_details_v1_document.py +++ b/mindee/product/fr/bank_account_details/bank_account_details_v1_document.py @@ -39,7 +39,6 @@ def __init__( ) def __str__(self) -> str: - return clean_out_string( f":IBAN: {self.iban}\n" f":Account Holder's Name: {self.account_holder_name}\n" diff --git a/mindee/product/fr/bank_account_details/bank_account_details_v2_document.py b/mindee/product/fr/bank_account_details/bank_account_details_v2_document.py index 6f660a6a..5a41745b 100644 --- a/mindee/product/fr/bank_account_details/bank_account_details_v2_document.py +++ b/mindee/product/fr/bank_account_details/bank_account_details_v2_document.py @@ -3,7 +3,7 @@ from mindee.parsing.common import Prediction, StringDict, clean_out_string from mindee.parsing.standard import StringField from mindee.product.fr.bank_account_details.bank_account_details_v2_bban import ( - BankAccountDetailsV2Bban, + BankAccountDetailsV2Bban, ) @@ -48,7 +48,6 @@ def __init__( ) def __str__(self) -> str: - return clean_out_string( f":Account Holder's Names: {self.account_holders_names}\n" f":Basic Bank Account Number:\n{self.bban.to_field_list()}\n" diff --git a/mindee/product/fr/carte_vitale/carte_vitale_v1_document.py b/mindee/product/fr/carte_vitale/carte_vitale_v1_document.py index 1dae5a82..0d18db46 100644 --- a/mindee/product/fr/carte_vitale/carte_vitale_v1_document.py +++ b/mindee/product/fr/carte_vitale/carte_vitale_v1_document.py @@ -48,7 +48,6 @@ def __str__(self) -> str: given_names = f"\n { ' ' * 15 }".join( [str(item) for item in self.given_names], ) - return clean_out_string( f":Given Name(s): {given_names}\n" f":Surname: {self.surname}\n" diff --git a/mindee/product/fr/id_card/id_card_v1_document.py b/mindee/product/fr/id_card/id_card_v1_document.py index aedff765..283b40a1 100644 --- a/mindee/product/fr/id_card/id_card_v1_document.py +++ b/mindee/product/fr/id_card/id_card_v1_document.py @@ -84,7 +84,6 @@ def __str__(self) -> str: given_names = f"\n { ' ' * 15 }".join( [str(item) for item in self.given_names], ) - return clean_out_string( f":Identity Number: {self.id_number}\n" f":Given Name(s): {given_names}\n" diff --git a/mindee/product/fr/id_card/id_card_v2_document.py b/mindee/product/fr/id_card/id_card_v2_document.py index f1c899b2..6901045b 100644 --- a/mindee/product/fr/id_card/id_card_v2_document.py +++ b/mindee/product/fr/id_card/id_card_v2_document.py @@ -114,7 +114,6 @@ def __str__(self) -> str: given_names = f"\n { ' ' * 15 }".join( [str(item) for item in self.given_names], ) - return clean_out_string( f":Nationality: {self.nationality}\n" f":Card Access Number: {self.card_access_number}\n" diff --git a/mindee/product/fr/id_card/id_card_v2_page.py b/mindee/product/fr/id_card/id_card_v2_page.py index 2fa55717..e74e80fa 100644 --- a/mindee/product/fr/id_card/id_card_v2_page.py +++ b/mindee/product/fr/id_card/id_card_v2_page.py @@ -36,5 +36,6 @@ def __init__( def __str__(self) -> str: return clean_out_string( - f":Document Type: {self.document_type}\n" f":Document Sides: {self.document_side}\n" + f"{super().__str__()}" + f":Document Type: {self.document_type}\n" + f":Document Sides: {self.document_side}\n" + f"{super().__str__()}" ) diff --git a/mindee/product/invoice/invoice_v4_document.py b/mindee/product/invoice/invoice_v4_document.py index 5cc3d8a3..a72eeb63 100644 --- a/mindee/product/invoice/invoice_v4_document.py +++ b/mindee/product/invoice/invoice_v4_document.py @@ -175,7 +175,6 @@ def __str__(self) -> str: supplier_payment_details = f"\n { ' ' * 26 }".join( [str(item) for item in self.supplier_payment_details], ) - return clean_out_string( f":Locale: {self.locale}\n" f":Invoice Number: {self.invoice_number}\n" diff --git a/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.py b/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.py index 09efa98c..206062e7 100644 --- a/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.py +++ b/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.py @@ -30,5 +30,4 @@ def __str__(self) -> str: receipts = f"\n { ' ' * 18 }".join( [str(item) for item in self.receipts], ) - return clean_out_string(f":List of Receipts: {receipts}\n") diff --git a/mindee/product/passport/passport_v1_document.py b/mindee/product/passport/passport_v1_document.py index e929b07c..724049f9 100644 --- a/mindee/product/passport/passport_v1_document.py +++ b/mindee/product/passport/passport_v1_document.py @@ -90,7 +90,6 @@ def __str__(self) -> str: given_names = f"\n { ' ' * 15 }".join( [str(item) for item in self.given_names], ) - return clean_out_string( f":Country Code: {self.country}\n" f":ID Number: {self.id_number}\n" diff --git a/mindee/product/proof_of_address/proof_of_address_v1_document.py b/mindee/product/proof_of_address/proof_of_address_v1_document.py index d1c03a96..00e91a38 100644 --- a/mindee/product/proof_of_address/proof_of_address_v1_document.py +++ b/mindee/product/proof_of_address/proof_of_address_v1_document.py @@ -89,7 +89,6 @@ def __str__(self) -> str: recipient_company_registration = f"\n { ' ' * 33 }".join( [str(item) for item in self.recipient_company_registration], ) - return clean_out_string( f":Locale: {self.locale}\n" f":Issuer Name: {self.issuer_name}\n" diff --git a/mindee/product/receipt/receipt_v5_document.py b/mindee/product/receipt/receipt_v5_document.py index 5172260d..2bd3845a 100644 --- a/mindee/product/receipt/receipt_v5_document.py +++ b/mindee/product/receipt/receipt_v5_document.py @@ -153,7 +153,6 @@ def __str__(self) -> str: supplier_company_registrations = f"\n { ' ' * 32 }".join( [str(item) for item in self.supplier_company_registrations], ) - return clean_out_string( f":Expense Locale: {self.locale}\n" f":Purchase Category: {self.category}\n" diff --git a/mindee/product/us/bank_check/bank_check_v1_document.py b/mindee/product/us/bank_check/bank_check_v1_document.py index a1070fb4..bb85c2da 100644 --- a/mindee/product/us/bank_check/bank_check_v1_document.py +++ b/mindee/product/us/bank_check/bank_check_v1_document.py @@ -60,7 +60,6 @@ def __str__(self) -> str: payees = f"\n { ' ' * 8 }".join( [str(item) for item in self.payees], ) - return clean_out_string( f":Check Issue Date: {self.date}\n" f":Amount: {self.amount}\n" diff --git a/mindee/product/us/bank_check/bank_check_v1_page.py b/mindee/product/us/bank_check/bank_check_v1_page.py index ab590f4b..7b2f4d3e 100644 --- a/mindee/product/us/bank_check/bank_check_v1_page.py +++ b/mindee/product/us/bank_check/bank_check_v1_page.py @@ -39,5 +39,6 @@ def __str__(self) -> str: [str(item) for item in self.signatures_positions], ) return clean_out_string( - f":Check Position: {self.check_position}\n" f":Signature Positions: {signatures_positions}\n" + f"{super().__str__()}" + f":Check Position: {self.check_position}\n" + f":Signature Positions: {signatures_positions}\n" + f"{super().__str__()}" ) diff --git a/mindee/product/us/driver_license/driver_license_v1_document.py b/mindee/product/us/driver_license/driver_license_v1_document.py index 2e2cb4fc..6485e8c8 100644 --- a/mindee/product/us/driver_license/driver_license_v1_document.py +++ b/mindee/product/us/driver_license/driver_license_v1_document.py @@ -123,7 +123,6 @@ def __init__( ) def __str__(self) -> str: - return clean_out_string( f":State: {self.state}\n" f":Driver License ID: {self.driver_license_id}\n" diff --git a/mindee/product/us/driver_license/driver_license_v1_page.py b/mindee/product/us/driver_license/driver_license_v1_page.py index 0f8da9b9..c0428414 100644 --- a/mindee/product/us/driver_license/driver_license_v1_page.py +++ b/mindee/product/us/driver_license/driver_license_v1_page.py @@ -38,5 +38,6 @@ def __init__( def __str__(self) -> str: return clean_out_string( - f":Photo: {self.photo}\n" f":Signature: {self.signature}\n" + f"{super().__str__()}" + f":Photo: {self.photo}\n" + f":Signature: {self.signature}\n" + f"{super().__str__()}" ) diff --git a/mindee/product/us/w9/w9_v1_document.py b/mindee/product/us/w9/w9_v1_document.py index f6499ffd..c96885c5 100644 --- a/mindee/product/us/w9/w9_v1_document.py +++ b/mindee/product/us/w9/w9_v1_document.py @@ -4,6 +4,5 @@ class W9V1Document(Prediction): """Document data for W9, API version 1.""" - def __str__(self) -> str: return "" diff --git a/mindee/product/us/w9/w9_v1_page.py b/mindee/product/us/w9/w9_v1_page.py index 44f72f39..7a34af65 100644 --- a/mindee/product/us/w9/w9_v1_page.py +++ b/mindee/product/us/w9/w9_v1_page.py @@ -96,7 +96,6 @@ def __init__( def __str__(self) -> str: return clean_out_string( - f":Name: {self.name}\n" f":SSN: {self.ssn}\n" f":Address: {self.address}\n" @@ -108,5 +107,6 @@ def __str__(self) -> str: f":W9 Revision Date: {self.w9_revision_date}\n" f":Signature Position: {self.signature_position}\n" f":Signature Date Position: {self.signature_date_position}\n" - f":Tax Classification LLC: {self.tax_classification_llc}\n" + f"{super().__str__()}" + f":Tax Classification LLC: {self.tax_classification_llc}\n" + + f"{super().__str__()}" ) diff --git a/tests/product/barcode_reader/test_barcode_reader_v1.py b/tests/product/barcode_reader/test_barcode_reader_v1.py index e8dfb61e..f7f5a5e6 100644 --- a/tests/product/barcode_reader/test_barcode_reader_v1.py +++ b/tests/product/barcode_reader/test_barcode_reader_v1.py @@ -35,7 +35,9 @@ def complete_page_0() -> Page[BarcodeReaderV1Document]: return Page(BarcodeReaderV1Document, json_data["document"]["inference"]["pages"][0]) -def test_complete_doc(complete_doc: Document[BarcodeReaderV1Document, Page[BarcodeReaderV1Document]]): +def test_complete_doc( + complete_doc: Document[BarcodeReaderV1Document, Page[BarcodeReaderV1Document]] +): reference_str = open( PRODUCT_DATA_DIR / "barcode_reader" / "response_v1" / "summary_full.rst", "r", @@ -44,7 +46,9 @@ def test_complete_doc(complete_doc: Document[BarcodeReaderV1Document, Page[Barco assert str(complete_doc) == reference_str -def test_empty_doc(empty_doc: Document[BarcodeReaderV1Document, Page[BarcodeReaderV1Document]]): +def test_empty_doc( + empty_doc: Document[BarcodeReaderV1Document, Page[BarcodeReaderV1Document]] +): prediction = empty_doc.inference.prediction assert len(prediction.codes_1d) == 0 assert len(prediction.codes_2d) == 0 diff --git a/tests/product/eu/license_plate/test_license_plate_v1.py b/tests/product/eu/license_plate/test_license_plate_v1.py index 48dccf25..4af7f048 100644 --- a/tests/product/eu/license_plate/test_license_plate_v1.py +++ b/tests/product/eu/license_plate/test_license_plate_v1.py @@ -35,7 +35,9 @@ def complete_page_0() -> Page[LicensePlateV1Document]: return Page(LicensePlateV1Document, json_data["document"]["inference"]["pages"][0]) -def test_complete_doc(complete_doc: Document[LicensePlateV1Document, Page[LicensePlateV1Document]]): +def test_complete_doc( + complete_doc: Document[LicensePlateV1Document, Page[LicensePlateV1Document]] +): reference_str = open( PRODUCT_DATA_DIR / "license_plates" / "response_v1" / "summary_full.rst", "r", @@ -44,7 +46,9 @@ def test_complete_doc(complete_doc: Document[LicensePlateV1Document, Page[Licens assert str(complete_doc) == reference_str -def test_empty_doc(empty_doc: Document[LicensePlateV1Document, Page[LicensePlateV1Document]]): +def test_empty_doc( + empty_doc: Document[LicensePlateV1Document, Page[LicensePlateV1Document]] +): prediction = empty_doc.inference.prediction assert len(prediction.license_plates) == 0 diff --git a/tests/product/fr/bank_account_details/test_bank_account_details_v1.py b/tests/product/fr/bank_account_details/test_bank_account_details_v1.py index 8d6d53f1..b7ca743a 100644 --- a/tests/product/fr/bank_account_details/test_bank_account_details_v1.py +++ b/tests/product/fr/bank_account_details/test_bank_account_details_v1.py @@ -12,15 +12,21 @@ @pytest.fixture -def complete_doc() -> Document[BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document]]: +def complete_doc() -> ( + Document[BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document]] +): json_data = json.load( - open(PRODUCT_DATA_DIR / "bank_account_details" / "response_v1" / "complete.json") + open( + PRODUCT_DATA_DIR / "bank_account_details" / "response_v1" / "complete.json" + ) ) return Document(BankAccountDetailsV1, json_data["document"]) @pytest.fixture -def empty_doc() -> Document[BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document]]: +def empty_doc() -> ( + Document[BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document]] +): json_data = json.load( open(PRODUCT_DATA_DIR / "bank_account_details" / "response_v1" / "empty.json") ) @@ -30,12 +36,20 @@ def empty_doc() -> Document[BankAccountDetailsV1Document, Page[BankAccountDetail @pytest.fixture def complete_page_0() -> Page[BankAccountDetailsV1Document]: json_data = json.load( - open(PRODUCT_DATA_DIR / "bank_account_details" / "response_v1" / "complete.json") + open( + PRODUCT_DATA_DIR / "bank_account_details" / "response_v1" / "complete.json" + ) + ) + return Page( + BankAccountDetailsV1Document, json_data["document"]["inference"]["pages"][0] ) - return Page(BankAccountDetailsV1Document, json_data["document"]["inference"]["pages"][0]) -def test_complete_doc(complete_doc: Document[BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document]]): +def test_complete_doc( + complete_doc: Document[ + BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document] + ] +): reference_str = open( PRODUCT_DATA_DIR / "bank_account_details" / "response_v1" / "summary_full.rst", "r", @@ -44,7 +58,11 @@ def test_complete_doc(complete_doc: Document[BankAccountDetailsV1Document, Page[ assert str(complete_doc) == reference_str -def test_empty_doc(empty_doc: Document[BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document]]): +def test_empty_doc( + empty_doc: Document[ + BankAccountDetailsV1Document, Page[BankAccountDetailsV1Document] + ] +): prediction = empty_doc.inference.prediction assert prediction.iban.value is None assert prediction.account_holder_name.value is None diff --git a/tests/product/fr/bank_account_details/test_bank_account_details_v2.py b/tests/product/fr/bank_account_details/test_bank_account_details_v2.py index a8fa3566..9003002e 100644 --- a/tests/product/fr/bank_account_details/test_bank_account_details_v2.py +++ b/tests/product/fr/bank_account_details/test_bank_account_details_v2.py @@ -12,15 +12,21 @@ @pytest.fixture -def complete_doc() -> Document[BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document]]: +def complete_doc() -> ( + Document[BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document]] +): json_data = json.load( - open(PRODUCT_DATA_DIR / "bank_account_details" / "response_v2" / "complete.json") + open( + PRODUCT_DATA_DIR / "bank_account_details" / "response_v2" / "complete.json" + ) ) return Document(BankAccountDetailsV2, json_data["document"]) @pytest.fixture -def empty_doc() -> Document[BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document]]: +def empty_doc() -> ( + Document[BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document]] +): json_data = json.load( open(PRODUCT_DATA_DIR / "bank_account_details" / "response_v2" / "empty.json") ) @@ -30,12 +36,20 @@ def empty_doc() -> Document[BankAccountDetailsV2Document, Page[BankAccountDetail @pytest.fixture def complete_page_0() -> Page[BankAccountDetailsV2Document]: json_data = json.load( - open(PRODUCT_DATA_DIR / "bank_account_details" / "response_v2" / "complete.json") + open( + PRODUCT_DATA_DIR / "bank_account_details" / "response_v2" / "complete.json" + ) + ) + return Page( + BankAccountDetailsV2Document, json_data["document"]["inference"]["pages"][0] ) - return Page(BankAccountDetailsV2Document, json_data["document"]["inference"]["pages"][0]) -def test_complete_doc(complete_doc: Document[BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document]]): +def test_complete_doc( + complete_doc: Document[ + BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document] + ] +): reference_str = open( PRODUCT_DATA_DIR / "bank_account_details" / "response_v2" / "summary_full.rst", "r", @@ -44,7 +58,11 @@ def test_complete_doc(complete_doc: Document[BankAccountDetailsV2Document, Page[ assert str(complete_doc) == reference_str -def test_empty_doc(empty_doc: Document[BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document]]): +def test_empty_doc( + empty_doc: Document[ + BankAccountDetailsV2Document, Page[BankAccountDetailsV2Document] + ] +): prediction = empty_doc.inference.prediction assert prediction.account_holders_names.value is None assert prediction.bban.bban_bank_code is None diff --git a/tests/product/fr/carte_vitale/test_carte_vitale_v1.py b/tests/product/fr/carte_vitale/test_carte_vitale_v1.py index d99af0e1..7e1f9ff1 100644 --- a/tests/product/fr/carte_vitale/test_carte_vitale_v1.py +++ b/tests/product/fr/carte_vitale/test_carte_vitale_v1.py @@ -35,7 +35,9 @@ def complete_page_0() -> Page[CarteVitaleV1Document]: return Page(CarteVitaleV1Document, json_data["document"]["inference"]["pages"][0]) -def test_complete_doc(complete_doc: Document[CarteVitaleV1Document, Page[CarteVitaleV1Document]]): +def test_complete_doc( + complete_doc: Document[CarteVitaleV1Document, Page[CarteVitaleV1Document]] +): reference_str = open( PRODUCT_DATA_DIR / "carte_vitale" / "response_v1" / "summary_full.rst", "r", @@ -44,7 +46,9 @@ def test_complete_doc(complete_doc: Document[CarteVitaleV1Document, Page[CarteVi assert str(complete_doc) == reference_str -def test_empty_doc(empty_doc: Document[CarteVitaleV1Document, Page[CarteVitaleV1Document]]): +def test_empty_doc( + empty_doc: Document[CarteVitaleV1Document, Page[CarteVitaleV1Document]] +): prediction = empty_doc.inference.prediction assert len(prediction.given_names) == 0 assert prediction.surname.value is None diff --git a/tests/product/invoice/test_invoice_v4.py b/tests/product/invoice/test_invoice_v4.py index 72aaa8bd..5b51b0ce 100644 --- a/tests/product/invoice/test_invoice_v4.py +++ b/tests/product/invoice/test_invoice_v4.py @@ -33,7 +33,9 @@ def complete_page_0() -> Page[InvoiceV4Document]: return Page(InvoiceV4Document, json_data["document"]["inference"]["pages"][0]) -def test_complete_doc(complete_doc: Document[InvoiceV4Document, Page[InvoiceV4Document]]): +def test_complete_doc( + complete_doc: Document[InvoiceV4Document, Page[InvoiceV4Document]] +): reference_str = open( PRODUCT_DATA_DIR / "invoices" / "response_v4" / "summary_full.rst", "r", diff --git a/tests/product/multi_receipts_detector/test_multi_receipts_detector_v1.py b/tests/product/multi_receipts_detector/test_multi_receipts_detector_v1.py index 980e13bc..bb8ae82e 100644 --- a/tests/product/multi_receipts_detector/test_multi_receipts_detector_v1.py +++ b/tests/product/multi_receipts_detector/test_multi_receipts_detector_v1.py @@ -12,17 +12,28 @@ @pytest.fixture -def complete_doc() -> Document[MultiReceiptsDetectorV1Document, Page[MultiReceiptsDetectorV1Document]]: +def complete_doc() -> ( + Document[MultiReceiptsDetectorV1Document, Page[MultiReceiptsDetectorV1Document]] +): json_data = json.load( - open(PRODUCT_DATA_DIR / "multi_receipts_detector" / "response_v1" / "complete.json") + open( + PRODUCT_DATA_DIR + / "multi_receipts_detector" + / "response_v1" + / "complete.json" + ) ) return Document(MultiReceiptsDetectorV1, json_data["document"]) @pytest.fixture -def empty_doc() -> Document[MultiReceiptsDetectorV1Document, Page[MultiReceiptsDetectorV1Document]]: +def empty_doc() -> ( + Document[MultiReceiptsDetectorV1Document, Page[MultiReceiptsDetectorV1Document]] +): json_data = json.load( - open(PRODUCT_DATA_DIR / "multi_receipts_detector" / "response_v1" / "empty.json") + open( + PRODUCT_DATA_DIR / "multi_receipts_detector" / "response_v1" / "empty.json" + ) ) return Document(MultiReceiptsDetectorV1, json_data["document"]) @@ -30,15 +41,28 @@ def empty_doc() -> Document[MultiReceiptsDetectorV1Document, Page[MultiReceiptsD @pytest.fixture def complete_page_0() -> Page[MultiReceiptsDetectorV1Document]: json_data = json.load( - open(PRODUCT_DATA_DIR / "multi_receipts_detector" / "response_v1" / "complete.json") + open( + PRODUCT_DATA_DIR + / "multi_receipts_detector" + / "response_v1" + / "complete.json" + ) + ) + return Page( + MultiReceiptsDetectorV1Document, json_data["document"]["inference"]["pages"][0] ) - return Page(MultiReceiptsDetectorV1Document, json_data["document"]["inference"]["pages"][0]) def test_complete_doc( - complete_doc: Document[MultiReceiptsDetectorV1Document, Page[MultiReceiptsDetectorV1Document]]): + complete_doc: Document[ + MultiReceiptsDetectorV1Document, Page[MultiReceiptsDetectorV1Document] + ] +): reference_str = open( - PRODUCT_DATA_DIR / "multi_receipts_detector" / "response_v1" / "summary_full.rst", + PRODUCT_DATA_DIR + / "multi_receipts_detector" + / "response_v1" + / "summary_full.rst", "r", encoding="utf-8", ).read() @@ -46,14 +70,20 @@ def test_complete_doc( def test_empty_doc( - empty_doc: Document[MultiReceiptsDetectorV1Document, Page[MultiReceiptsDetectorV1Document]]): + empty_doc: Document[ + MultiReceiptsDetectorV1Document, Page[MultiReceiptsDetectorV1Document] + ] +): prediction = empty_doc.inference.prediction assert len(prediction.receipts) == 0 def test_complete_page_0(complete_page_0: Page[MultiReceiptsDetectorV1Document]): reference_str = open( - PRODUCT_DATA_DIR / "multi_receipts_detector" / "response_v1" / "summary_page0.rst", + PRODUCT_DATA_DIR + / "multi_receipts_detector" + / "response_v1" + / "summary_page0.rst", "r", encoding="utf-8", ).read() diff --git a/tests/product/passport/test_passport_v1.py b/tests/product/passport/test_passport_v1.py index 75c50094..e72b9ce3 100644 --- a/tests/product/passport/test_passport_v1.py +++ b/tests/product/passport/test_passport_v1.py @@ -33,7 +33,9 @@ def complete_page_0() -> Page[PassportV1Document]: return Page(PassportV1Document, json_data["document"]["inference"]["pages"][0]) -def test_complete_doc(complete_doc: Document[PassportV1Document, Page[PassportV1Document]]): +def test_complete_doc( + complete_doc: Document[PassportV1Document, Page[PassportV1Document]] +): reference_str = open( PRODUCT_DATA_DIR / "passport" / "response_v1" / "summary_full.rst", "r", diff --git a/tests/product/proof_of_address/test_proof_of_address_v1.py b/tests/product/proof_of_address/test_proof_of_address_v1.py index def38f4e..49f6117b 100644 --- a/tests/product/proof_of_address/test_proof_of_address_v1.py +++ b/tests/product/proof_of_address/test_proof_of_address_v1.py @@ -12,7 +12,9 @@ @pytest.fixture -def complete_doc() -> Document[ProofOfAddressV1Document, Page[ProofOfAddressV1Document]]: +def complete_doc() -> ( + Document[ProofOfAddressV1Document, Page[ProofOfAddressV1Document]] +): json_data = json.load( open(PRODUCT_DATA_DIR / "proof_of_address" / "response_v1" / "complete.json") ) @@ -32,10 +34,14 @@ def complete_page_0() -> Page[ProofOfAddressV1Document]: json_data = json.load( open(PRODUCT_DATA_DIR / "proof_of_address" / "response_v1" / "complete.json") ) - return Page(ProofOfAddressV1Document, json_data["document"]["inference"]["pages"][0]) + return Page( + ProofOfAddressV1Document, json_data["document"]["inference"]["pages"][0] + ) -def test_complete_doc(complete_doc: Document[ProofOfAddressV1Document, Page[ProofOfAddressV1Document]]): +def test_complete_doc( + complete_doc: Document[ProofOfAddressV1Document, Page[ProofOfAddressV1Document]] +): reference_str = open( PRODUCT_DATA_DIR / "proof_of_address" / "response_v1" / "summary_full.rst", "r", @@ -44,7 +50,9 @@ def test_complete_doc(complete_doc: Document[ProofOfAddressV1Document, Page[Proo assert str(complete_doc) == reference_str -def test_empty_doc(empty_doc: Document[ProofOfAddressV1Document, Page[ProofOfAddressV1Document]]): +def test_empty_doc( + empty_doc: Document[ProofOfAddressV1Document, Page[ProofOfAddressV1Document]] +): prediction = empty_doc.inference.prediction assert prediction.locale.value is None assert prediction.issuer_name.value is None diff --git a/tests/product/receipt/test_receipt_v5.py b/tests/product/receipt/test_receipt_v5.py index 43a6fc3a..8da54007 100644 --- a/tests/product/receipt/test_receipt_v5.py +++ b/tests/product/receipt/test_receipt_v5.py @@ -33,7 +33,9 @@ def complete_page_0() -> Page[ReceiptV5Document]: return Page(ReceiptV5Document, json_data["document"]["inference"]["pages"][0]) -def test_complete_doc(complete_doc: Document[ReceiptV5Document, Page[ReceiptV5Document]]): +def test_complete_doc( + complete_doc: Document[ReceiptV5Document, Page[ReceiptV5Document]] +): reference_str = open( PRODUCT_DATA_DIR / "expense_receipts" / "response_v5" / "summary_full.rst", "r", diff --git a/tests/product/us/bank_check/test_bank_check_v1.py b/tests/product/us/bank_check/test_bank_check_v1.py index 154a755d..ae84b94b 100644 --- a/tests/product/us/bank_check/test_bank_check_v1.py +++ b/tests/product/us/bank_check/test_bank_check_v1.py @@ -34,7 +34,9 @@ def complete_page_0() -> Page[BankCheckV1Page]: return Page(BankCheckV1Page, json_data["document"]["inference"]["pages"][0]) -def test_complete_doc(complete_doc: Document[BankCheckV1Document, Page[BankCheckV1Page]]): +def test_complete_doc( + complete_doc: Document[BankCheckV1Document, Page[BankCheckV1Page]] +): reference_str = open( PRODUCT_DATA_DIR / "bank_check" / "response_v1" / "summary_full.rst", "r", diff --git a/tests/product/us/driver_license/test_driver_license_v1.py b/tests/product/us/driver_license/test_driver_license_v1.py index 5af7fbb3..152b4b2c 100644 --- a/tests/product/us/driver_license/test_driver_license_v1.py +++ b/tests/product/us/driver_license/test_driver_license_v1.py @@ -36,7 +36,9 @@ def complete_page_0() -> Page[DriverLicenseV1Page]: return Page(DriverLicenseV1Page, json_data["document"]["inference"]["pages"][0]) -def test_complete_doc(complete_doc: Document[DriverLicenseV1Document, Page[DriverLicenseV1Page]]): +def test_complete_doc( + complete_doc: Document[DriverLicenseV1Document, Page[DriverLicenseV1Page]] +): reference_str = open( PRODUCT_DATA_DIR / "us_driver_license" / "response_v1" / "summary_full.rst", "r", @@ -45,7 +47,9 @@ def test_complete_doc(complete_doc: Document[DriverLicenseV1Document, Page[Drive assert str(complete_doc) == reference_str -def test_empty_doc(empty_doc: Document[DriverLicenseV1Document, Page[DriverLicenseV1Page]]): +def test_empty_doc( + empty_doc: Document[DriverLicenseV1Document, Page[DriverLicenseV1Page]] +): prediction = empty_doc.inference.prediction assert prediction.state.value is None assert prediction.driver_license_id.value is None