def test_rewrite_address_block_end_to_end(pdf_data, address_snippet): new_pdf, address, message = rewrite_address_block( BytesIO(pdf_data), page_count=1, allow_international_letters=False, ) assert not message assert address == extract_address_block(new_pdf).raw_address assert address_snippet in address.lower()
def test_rewrite_address_block_doesnt_overwrite_if_it_cant_redact_address(): old_pdf = BytesIO(repeated_address_block) old_address = extract_address_block(old_pdf).raw_address new_pdf, address, message = rewrite_address_block( old_pdf, page_count=1, allow_international_letters=False, ) # assert that the pdf is unchanged. Specifically we haven't written the new address over the old one assert new_pdf.getvalue() == old_pdf.getvalue() assert message == 'More than one match for address block during redaction procedure' # template preview still needs to return the address even though it's unchanged. assert old_address == address