Example #1
0
def ocr_result_sat_coupon_1():
    """ OCR test data for a sat coupon 1. """
    OCR_TEST_RESULT_FOLDER = "./tests/data/ocr_results/"

    ocr_result = open_file(OCR_TEST_RESULT_FOLDER + "sat_coupon_1.txt")

    return ocr_result
Example #2
0
def ocr_result_no_match_1():
    """ OCR test data for unknown receipt structure."""
    OCR_TEST_RESULT_FOLDER = "./tests/data/ocr_results/"

    ocr_result = open_file(OCR_TEST_RESULT_FOLDER + "no_match_1.txt")

    return ocr_result
Example #3
0
def pre_processed_tax_coupon_2():
    """ OCR test data for tax coupon 3."""
    OCR_TEST_RESULT_FOLDER = "./tests/data/ocr_results/"

    ocr_result = open_file(OCR_TEST_RESULT_FOLDER +
                           "tax_coupon_preprocessed_3.txt")

    return ocr_result
Example #4
0
def test_regex4ocr_function(mocked_scan_drms_folder, mocked_parse_ocr_result,
                            ocr_test_rslt_folder):
    """
    Unit: Tests regex4ocr function logic.
    """
    ocr_result = open_file(ocr_test_rslt_folder + "tax_coupon_1.txt")
    drms_path = "./drms"

    mocked_drms_1 = {"test": 1}
    mocked_drms_2 = {"test": 2}

    mocked_scan_drms_folder.return_value = [mocked_drms_1, mocked_drms_2]
    mocked_parse_ocr_result.return_value = "test_parsed_ocr_result"

    assert parse(ocr_result, drms_path) == "test_parsed_ocr_result"

    mocked_scan_drms_folder.assert_called_once_with(drms_path)
    mocked_parse_ocr_result.assert_called_once_with(
        ocr_result, [mocked_drms_1, mocked_drms_2])