Skip to content

Commit

Permalink
add blank document tests (Azure#25152)
Browse files Browse the repository at this point in the history
  • Loading branch information
catalinaperalta authored Jul 13, 2022
1 parent 1ce80f0 commit 443cbb2
Show file tree
Hide file tree
Showing 4 changed files with 484 additions and 0 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,26 @@ def test_custom_document_signature_field(self, client, formrecognizer_storage_co
assert result.documents[0].fields.get("FullSignature").value_type == "signature"
# this will notify us of changes in the service, currently expecting to get a None content for signature type fields
assert result.documents[0].fields.get("FullSignature").content == None

@FormRecognizerPreparer()
@DocumentModelAdministrationClientPreparer()
@recorded_by_proxy
def test_custom_document_blank_pdf(self, client, formrecognizer_storage_container_sas_url, **kwargs):
set_bodiless_matcher()
da_client = client.get_document_analysis_client()

with open(self.blank_pdf, "rb") as fd:
my_file = fd.read()

build_polling = client.begin_build_model(formrecognizer_storage_container_sas_url, "template")
model = build_polling.result()

poller = da_client.begin_analyze_document(
model.model_id,
my_file,
)
result = poller.result()

assert result is not None
assert len(result.pages) == 1
assert len(result.pages[0].lines) == 0
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,28 @@ async def test_custom_document_signature_field(self, client, formrecognizer_stor
assert result.documents[0].fields.get("FullSignature").value_type == "signature"
# this will notify us of changes in the service, currently expecting to get a None content for signature type fields
assert result.documents[0].fields.get("FullSignature").content == None

@FormRecognizerPreparer()
@DocumentModelAdministrationClientPreparer()
@recorded_by_proxy_async
async def test_custom_document_blank_pdf(self, client, formrecognizer_storage_container_sas_url, **kwargs):
set_bodiless_matcher()
da_client = client.get_document_analysis_client()

with open(self.blank_pdf, "rb") as fd:
my_file = fd.read()

async with client:
build_polling = await client.begin_build_model(formrecognizer_storage_container_sas_url, "template")
model = await build_polling.result()

async with da_client:
poller = await da_client.begin_analyze_document(
model.model_id,
my_file,
)
result = await poller.result()

assert result is not None
assert len(result.pages) == 1
assert len(result.pages[0].lines) == 0

0 comments on commit 443cbb2

Please sign in to comment.