Skip to content

Commit

Permalink
[formrecognizer] fix failing tests (#21774)
Browse files Browse the repository at this point in the history
* move pytest decorator

* more instances
  • Loading branch information
kristapratico authored Nov 16, 2021
1 parent a2f7db3 commit ebd9fc2
Show file tree
Hide file tree
Showing 30 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def callback(response, _, headers):
document_model_from_dict = DocumentModel.from_dict(document_model_dict)
self.assertModelTransformCorrect(document_model_from_dict, generated)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@DocumentModelAdministrationClientPreparer()
@pytest.mark.live_test_only
def test_compose_continuation_token(self, client, formrecognizer_storage_container_sas_url):

poller = client.begin_build_model(formrecognizer_storage_container_sas_url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ def callback(response, _, headers):
document_model_from_dict = DocumentModel.from_dict(document_model_dict)
self.assertModelTransformCorrect(document_model_from_dict, generated)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@DocumentModelAdministrationClientPreparer()
@pytest.mark.live_test_only
async def test_compose_continuation_token(self, client, formrecognizer_storage_container_sas_url):

async with client:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ def callback(raw_response, _, headers):
# Check form pages
self.assertFormPagesTransformCorrect(layout, read_results, page_results)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormRecognizerClientPreparer()
@pytest.mark.live_test_only
def test_content_continuation_token(self, client):
with open(self.form_jpg, "rb") as fd:
myfile = fd.read()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ def callback(raw_response, _, headers):
# Check form pages
self.assertFormPagesTransformCorrect(layout, read_results, page_results)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormRecognizerClientPreparer()
@pytest.mark.live_test_only
async def test_content_continuation_token(self, client):
with open(self.form_jpg, "rb") as fd:
myfile = fd.read()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ def callback(raw_response, _, headers):
# Check form pages
self.assertFormPagesTransformCorrect(layout, read_results, page_results)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormRecognizerClientPreparer()
@pytest.mark.live_test_only
def test_content_continuation_token(self, client):
initial_poller = client.begin_recognize_content_from_url(self.form_url_jpg)
cont_token = initial_poller.continuation_token()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def callback(raw_response, _, headers):
# Check form pages
self.assertFormPagesTransformCorrect(layout, read_results, page_results)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormRecognizerClientPreparer()
@pytest.mark.live_test_only
async def test_content_continuation_token(self, client):
async with client:
initial_poller = await client.begin_recognize_content_from_url(self.form_url_jpg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ def test_copy_model_with_composed_model(self, client, formrecognizer_storage_con
assert field["type"]
assert doc_type.field_confidence[key] is not None

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@DocumentModelAdministrationClientPreparer()
@pytest.mark.live_test_only
def test_copy_continuation_token(self, client, formrecognizer_storage_container_sas_url):

poller = client.begin_build_model(formrecognizer_storage_container_sas_url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ async def test_copy_model_with_composed_model(self, client, formrecognizer_stora
assert field["type"]
assert doc_type.field_confidence[key] is not None

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@DocumentModelAdministrationClientPreparer()
@pytest.mark.live_test_only
async def test_copy_continuation_token(self, client, formrecognizer_storage_container_sas_url):
async with client:
poller = await client.begin_build_model(formrecognizer_storage_container_sas_url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ def callback(raw_response, _, headers):
# check page range
assert len(raw_analyze_result.pages) == len(returned_model.pages)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormTrainingClientPreparer()
@pytest.mark.live_test_only
def test_custom_form_continuation_token(self, client, formrecognizer_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ def callback(raw_response, _, headers):
# check page range
assert len(raw_analyze_result.pages) == len(returned_model.pages)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormTrainingClientPreparer()
@pytest.mark.live_test_only
async def test_custom_form_continuation_token(self, client, formrecognizer_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()
with open(self.form_jpg, "rb") as fd:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def callback(raw_response, _, headers):
self.assertEqual(form.model_id, model.model_id)
self.assertFormFieldsTransformCorrect(form.fields, actual.fields, read_results)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormTrainingClientPreparer()
@pytest.mark.live_test_only
def test_custom_form_continuation_token(self, client, formrecognizer_storage_container_sas_url_v2):
fr_client = client.get_form_recognizer_client()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ def callback(raw_response, _, headers):
self.assertEqual(form.model_id, model.model_id)
self.assertFormFieldsTransformCorrect(form.fields, actual.fields, read_results)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormTrainingClientPreparer()
@pytest.mark.live_test_only
async def test_custom_form_continuation_token(self, client, formrecognizer_storage_container_sas_url):
fr_client = client.get_form_recognizer_client()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ def test_identity_document_jpg_include_field_elements(self, client):
else:
self.assertFieldElementsHasValues(field.value_data.field_elements, id_document.page_range.first_page_number)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormRecognizerClientPreparer()
@pytest.mark.live_test_only
def test_identity_document_continuation_token(self, client):
with open(self.identity_document_license_jpg, "rb") as fd:
id_document = fd.read()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ async def test_identity_document_jpg_include_field_elements(self, client):
else:
self.assertFieldElementsHasValues(field.value_data.field_elements, id_document.page_range.first_page_number)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormRecognizerClientPreparer()
@pytest.mark.live_test_only
async def test_identity_document_continuation_token(self, client):
with open(self.identity_document_license_jpg, "rb") as fd:
id_document = fd.read()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ def test_identity_document_jpg_include_field_elements(self, client):
else:
self.assertFieldElementsHasValues(field.value_data.field_elements, id_document.page_range.first_page_number)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormRecognizerClientPreparer()
@pytest.mark.live_test_only
def test_identity_document_continuation_token(self, client):
initial_poller = client.begin_recognize_identity_documents_from_url(self.identity_document_url_jpg)
cont_token = initial_poller.continuation_token()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ async def test_identity_document_jpg_include_field_elements(self, client):
else:
self.assertFieldElementsHasValues(field.value_data.field_elements, id_document.page_range.first_page_number)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormRecognizerClientPreparer()
@pytest.mark.live_test_only
async def test_identity_document_continuation_token(self, client):
async with client:
initial_poller = await client.begin_recognize_identity_documents_from_url(self.identity_document_url_jpg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ def test_invoice_jpg_include_field_elements(self, client):
self.assertEqual(invoice.fields.get("Items").value[0].value["Quantity"].value, 1.0)
self.assertEqual(invoice.fields.get("Items").value[0].value["UnitPrice"].value, 1.0)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormRecognizerClientPreparer()
@pytest.mark.live_test_only
def test_invoice_continuation_token(self, client):

with open(self.invoice_tiff, "rb") as fd:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ async def test_invoice_jpg_include_field_elements(self, client):
self.assertEqual(invoice.fields.get("Items").value[0].value["Quantity"].value, 1.0)
self.assertEqual(invoice.fields.get("Items").value[0].value["UnitPrice"].value, 1.0)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormRecognizerClientPreparer()
@pytest.mark.live_test_only
async def test_invoice_continuation_token(self, client):

with open(self.invoice_tiff, "rb") as fd:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def test_invoice_tiff(self, client):
self.assertEqual(invoice.fields.get("Items").value[0].value["Amount"].value, 56651.49)
self.assertEqual(invoice.fields.get("DueDate").value, date(2017, 6, 24))

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormRecognizerClientPreparer()
@pytest.mark.live_test_only
def test_invoice_continuation_token(self, client):

initial_poller = client.begin_recognize_invoices_from_url(self.invoice_url_tiff)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ async def test_invoice_tiff(self, client):
self.assertEqual(invoice.fields.get("Items").value[0].value["Amount"].value, 56651.49)
self.assertEqual(invoice.fields.get("DueDate").value, date(2017, 6, 24))

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@FormRecognizerClientPreparer()
@pytest.mark.live_test_only
async def test_invoice_continuation_token(self, client):
async with client:
initial_poller = await client.begin_recognize_invoices_from_url(self.invoice_url_tiff)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def emit(self, record):

class TestLogging(FormRecognizerTest):

@FormRecognizerPreparer()
@pytest.mark.live_test_only
@FormRecognizerPreparer()
def test_logging_info_dac_client(self, formrecognizer_test_endpoint, formrecognizer_test_api_key):
client = DocumentAnalysisClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key))
mock_handler = MockHandler()
Expand All @@ -51,8 +51,8 @@ def test_logging_info_dac_client(self, formrecognizer_test_endpoint, formrecogni
else:
assert message.message.find("REDACTED") == -1

@FormRecognizerPreparer()
@pytest.mark.live_test_only
@FormRecognizerPreparer()
def test_logging_info_dmac_client(self, formrecognizer_test_endpoint, formrecognizer_test_api_key):
client = DocumentModelAdministrationClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key))
mock_handler = MockHandler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def __init__(self, *args, **kwargs):

class TestLogging(AsyncFormRecognizerTest):

@FormRecognizerPreparer()
@pytest.mark.live_test_only
@FormRecognizerPreparer()
async def test_logging_info_dac_client(self, formrecognizer_test_endpoint, formrecognizer_test_api_key):
client = DocumentAnalysisClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key))
mock_handler = MockHandler()
Expand All @@ -86,8 +86,8 @@ async def test_logging_info_dac_client(self, formrecognizer_test_endpoint, formr
else:
assert message.message.find("REDACTED") == -1

@FormRecognizerPreparer()
@pytest.mark.live_test_only
@FormRecognizerPreparer()
async def test_logging_info_dmac_client(self, formrecognizer_test_endpoint, formrecognizer_test_api_key):
client = DocumentModelAdministrationClient(formrecognizer_test_endpoint, AzureKeyCredential(formrecognizer_test_api_key))
mock_handler = MockHandler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

class TestManagement(FormRecognizerTest):

@FormRecognizerPreparer()
@pytest.mark.live_test_only
@FormRecognizerPreparer()
def test_active_directory_auth(self):
token = self.generate_oauth_token()
endpoint = self.get_oauth_endpoint()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

class TestManagementAsync(AsyncFormRecognizerTest):

@FormRecognizerPreparer()
@pytest.mark.live_test_only
@FormRecognizerPreparer()
async def test_active_directory_auth_async(self):
token = self.generate_oauth_token()
endpoint = self.get_oauth_endpoint()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@ def callback(raw_response, _, headers):
# check page range
assert len(raw_analyze_result.pages) == len(returned_model.pages)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@GlobalClientPreparer()
@pytest.mark.live_test_only
def test_receipt_continuation_token(self, client):

with open(self.receipt_jpg, "rb") as fd:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,9 @@ def callback(raw_response, _, headers):
# check page range
assert len(raw_analyze_result.pages) == len(returned_model.pages)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@GlobalClientPreparer()
@pytest.mark.live_test_only
async def test_receipt_continuation_token(self, client):

with open(self.receipt_jpg, "rb") as fd:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ def callback(raw_response, _, headers):
# check page range
assert len(raw_analyze_result.pages) == len(returned_model.pages)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@GlobalClientPreparer()
@pytest.mark.live_test_only
def test_receipt_continuation_token(self, client):

initial_poller = client.begin_analyze_document_from_url("prebuilt-receipt", self.receipt_url_jpg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ def callback(raw_response, _, headers):
# check page range
assert len(raw_analyze_result.pages) == len(returned_model.pages)

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@GlobalClientPreparer()
@pytest.mark.live_test_only
async def test_receipt_continuation_token(self, client):

async with client:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ def test_build_model_azure_blob_path_filter(self, client, formrecognizer_storage
poller = client.begin_build_model(formrecognizer_storage_container_sas_url, prefix="subfolder")
model = poller.result()

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@DocumentModelAdministrationClientPreparer()
@pytest.mark.live_test_only
def test_build_model_continuation_token(self, client, formrecognizer_storage_container_sas_url):

initial_poller = client.begin_build_model(formrecognizer_storage_container_sas_url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ async def test_build_model_azure_blob_path_filter(self, client, formrecognizer_s
poller = await client.begin_build_model(formrecognizer_storage_container_sas_url, prefix="subfolder")
model = await poller.result()

@pytest.mark.live_test_only
@FormRecognizerPreparer()
@DocumentModelAdministrationClientPreparer()
@pytest.mark.live_test_only
async def test_build_model_continuation_token(self, client, formrecognizer_storage_container_sas_url):
async with client:
initial_poller = await client.begin_build_model(formrecognizer_storage_container_sas_url)
Expand Down

0 comments on commit ebd9fc2

Please sign in to comment.