def test_batch_inserts(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): set_bodiless_matcher() # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key, url="cosmos") try: # Act entity = TableEntity() entity['PartitionKey'] = 'batch_inserts' entity['test'] = EntityProperty(True, EdmType.BOOLEAN) entity['test2'] = 'value' entity['test3'] = 3 entity['test4'] = EntityProperty(1234567890, EdmType.INT32) transaction_count = 0 batch = [] for i in range(100): entity['RowKey'] = str(i) batch.append(('create', entity.copy())) transaction_count += 1 transaction_result = self.table.submit_transaction(batch) # Assert self._assert_valid_batch_transaction(transaction_result, transaction_count) assert 'etag' in transaction_result[0] entities = list(self.table.query_entities("PartitionKey eq 'batch_inserts'")) # Assert assert entities is not None assert transaction_count == len(entities) e = self.table.get_entity('batch_inserts', '1') finally: self._tear_down()
async def test_content_multipage_url(self, client): set_bodiless_matcher() async with client: poller = await client.begin_recognize_content_from_url(self.multipage_url_pdf) result = await poller.result() assert len(result) == 3 self.assertFormPagesHasValues(result)
def test_batch_update_if_doesnt_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): set_bodiless_matcher() # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key, url="cosmos") try: entity = self._create_random_entity_dict() self.table.create_entity(entity) # Act sent_entity1 = self._create_updated_entity_dict(entity['PartitionKey'], entity['RowKey']) batch = [( 'update', sent_entity1, {'etag': u'W/"datetime\'2012-06-15T22%3A51%3A44.9662825Z\'"', 'match_condition':MatchConditions.IfNotModified} )] with pytest.raises(TableTransactionError) as error: self.table.submit_transaction(batch) assert error.value.status_code == 412 assert error.value.error_code == TableErrorCode.update_condition_not_satisfied # Assert received_entity = self.table.get_entity(entity['PartitionKey'], entity['RowKey']) self._assert_default_entity(received_entity) finally: self._tear_down()
async def test_batch_request_too_large(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): set_bodiless_matcher() # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key, url="cosmos") try: batch = [] entity = { 'PartitionKey': 'pk001', 'Foo': os.urandom(1024 * 64), 'Bar': os.urandom(1024 * 64), 'Baz': os.urandom(1024 * 64) } for i in range(20): entity['RowKey'] = str(i) batch.append(('create', entity.copy())) with pytest.raises(RequestTooLargeError): await self.table.submit_transaction(batch) finally: await self._tear_down()
def test_compose_model_transform(self, client, formrecognizer_storage_container_sas_url, **kwargs): set_bodiless_matcher() poller = client.begin_build_model( formrecognizer_storage_container_sas_url, description="model1") model_1 = poller.result() poller = client.begin_build_model( formrecognizer_storage_container_sas_url, description="model2") model_2 = poller.result() raw_response = [] def callback(response, _, headers): op_response = client._deserialize(GetOperationResponse, response) model_info = client._deserialize(ModelInfo, op_response.result) document_model = DocumentModel._from_generated(model_info) raw_response.append(model_info) raw_response.append(document_model) poller = client.begin_create_composed_model( [model_1.model_id, model_2.model_id], description="my composed model", cls=callback) model = poller.result() generated = raw_response[0] document_model = raw_response[1] self.assertModelTransformCorrect(document_model, generated) document_model_dict = document_model.to_dict() document_model_from_dict = DocumentModel.from_dict(document_model_dict) self.assertModelTransformCorrect(document_model_from_dict, generated)
async def test_training_without_labels_v2( self, client, formrecognizer_storage_container_sas_url_v2, **kwargs): set_bodiless_matcher() async with client: poller = await client.begin_training( training_files_url=formrecognizer_storage_container_sas_url_v2, use_training_labels=True) model = await poller.result() model_dict = model.to_dict() model = CustomFormModel.from_dict(model_dict) assert model.model_id assert model.training_started_on assert model.training_completed_on assert model.errors == [] assert model.status == "ready" for doc in model.training_documents: assert doc.name assert doc.page_count assert doc.status assert doc.errors == [] for sub in model.submodels: assert sub.form_type assert sub.accuracy is not None for key, field in sub.fields.items(): assert field.accuracy is not None assert field.name
async def test_batch_single_insert(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): set_bodiless_matcher() # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key, url="cosmos") try: # Act entity = TableEntity() entity['PartitionKey'] = '001' entity['RowKey'] = 'batch_insert' entity['test'] = EntityProperty(True, EdmType.BOOLEAN) entity['test2'] = 'value' entity['test3'] = 3 entity['test4'] = EntityProperty(1234567890, EdmType.INT32) entity['test5'] = datetime.utcnow() batch = [('create', entity)] transaction_result = await self.table.submit_transaction(batch) # Assert self._assert_valid_batch_transaction(transaction_result, 1) assert 'etag' in transaction_result[0] e = await self.table.get_entity( row_key=entity['RowKey'], partition_key=entity['PartitionKey']) assert e['test'] == entity['test'].value assert e['test2'] == entity['test2'] assert e['test3'] == entity['test3'] assert e['test4'] == entity['test4'].value finally: await self._tear_down()
async def test_invoice_tiff(self, client): set_bodiless_matcher() async with client: poller = await client.begin_analyze_document_from_url( model="prebuilt-invoice", document_url=self.invoice_url_tiff) result = await poller.result() assert len(result.documents) == 1 invoice = result.documents[0] # check dict values assert invoice.fields.get("VendorName").value == "Contoso" assert invoice.fields.get( "VendorAddress" ).value, '1 Redmond way Suite 6000 Redmond == WA 99243' assert invoice.fields.get( "CustomerAddressRecipient").value == "Microsoft" assert invoice.fields.get( "CustomerAddress" ).value, '1020 Enterprise Way Sunnayvale == CA 87659' assert invoice.fields.get("CustomerName").value == "Microsoft" assert invoice.fields.get("InvoiceId").value == '34278587' assert invoice.fields.get("InvoiceDate").value, date(2017, 6 == 18) assert invoice.fields.get( "Items").value[0].value["Amount"].value == 56651.49 assert invoice.fields.get("DueDate").value, date(2017, 6 == 24)
async def test_receipts_encoded_url(self, client): set_bodiless_matcher() with pytest.raises(HttpResponseError) as e: async with client: poller = await client.begin_analyze_document_from_url( "prebuilt-receipt", "https://fakeuri.com/blank%20space") assert "https://fakeuri.com/blank%20space" in e.value.response.request.body
async def test_receipt_multipage_url(self, client): set_bodiless_matcher() async with client: poller = await client.begin_analyze_document_from_url("prebuilt-receipt", self.multipage_receipt_url_pdf) result = await poller.result() assert len(result.documents) == 2 receipt = result.documents[0] assert receipt.fields.get("MerchantAddress").value, '123 Main Street Redmond == WA 98052' assert receipt.fields.get("MerchantName").value == 'Contoso' assert receipt.fields.get("MerchantPhoneNumber").value == '+19876543210' assert receipt.fields.get("Subtotal").value == 11.7 assert receipt.fields.get("TotalTax").value == 1.17 assert receipt.fields.get("Tip").value == 1.63 assert receipt.fields.get("Total").value == 14.5 assert receipt.fields.get("TransactionDate").value == date(year=2019, month=6, day=10) assert receipt.fields.get("TransactionTime").value == time(hour=13, minute=59, second=0) assert receipt.doc_type == "receipt.retailMeal" receipt = result.documents[1] assert receipt.fields.get("MerchantAddress").value, '123 Main Street Redmond == WA 98052' assert receipt.fields.get("MerchantName").value == 'Contoso' assert receipt.fields.get("Subtotal").value == 1098.99 assert receipt.fields.get("TotalTax").value == 104.4 assert receipt.fields.get("Total").value == 1203.39 assert receipt.fields.get("TransactionDate").value == date(year=2019, month=6, day=10) assert receipt.fields.get("TransactionTime").value == time(hour=13, minute=59, second=0) assert receipt.doc_type == "receipt.retailMeal" assert len(result.pages) == 2 return {}
async def test_copy_model_with_unlabeled_model_name_v21( self, client, formrecognizer_storage_container_sas_url_v2, formrecognizer_region, formrecognizer_resource_id, **kwargs): set_bodiless_matcher() async with client: poller = await client.begin_training( formrecognizer_storage_container_sas_url_v2, use_training_labels=False, model_name="mymodel") model = await poller.result() target = await client.get_copy_authorization( resource_region=formrecognizer_region, resource_id=formrecognizer_resource_id) poller = await client.begin_copy_model(model.model_id, target=target) copy = await poller.result() copied_model = await client.get_custom_model(copy.model_id) assert copy.status == "ready" assert copy.training_started_on assert copy.training_completed_on assert target["modelId"] == copy.model_id assert target["modelId"] != model.model_id assert copied_model assert copied_model.model_name == "mymodel"
async def test_business_card_multipage_pdf(self, client): set_bodiless_matcher() async with client: poller = await client.begin_analyze_document_from_url("prebuilt-businessCard", self.business_card_multipage_url_pdf) result = await poller.result() assert len(result.documents) == 2 business_card = result.documents[0] assert len(business_card.fields.get("ContactNames").value) == 1 assert business_card.fields.get("ContactNames").value[0].value['FirstName'].value == 'JOHN' assert business_card.fields.get("ContactNames").value[0].value['LastName'].value == 'SINGER' assert len(business_card.fields.get("JobTitles").value) == 1 assert business_card.fields.get("JobTitles").value[0].value == "Software Engineer" assert len(business_card.fields.get("Emails").value) == 1 assert business_card.fields.get("Emails").value[0].value == "*****@*****.**" assert len(business_card.fields.get("Websites").value) == 1 assert business_card.fields.get("Websites").value[0].value == "https://www.contoso.com" # FIXME: the service is not returning this currently # assert len(business_card.fields.get("OtherPhones").value) == 1 # assert business_card.fields.get("OtherPhones").value[0].value == "+14257793479" business_card = result.documents[1] assert len(business_card.fields.get("ContactNames").value) == 1 assert business_card.fields.get("ContactNames").value[0].value['FirstName'].value == 'Avery' assert business_card.fields.get("ContactNames").value[0].value['LastName'].value == 'Smith' assert len(business_card.fields.get("JobTitles").value) == 1 assert business_card.fields.get("JobTitles").value[0].value == "Senior Researcher" assert len(business_card.fields.get("Departments").value) == 1 assert business_card.fields.get("Departments").value[0].value == "Cloud & Al Department" assert len(business_card.fields.get("Emails").value) == 1 assert business_card.fields.get("Emails").value[0].value == "*****@*****.**" assert len(business_card.fields.get("Websites").value) == 1 assert business_card.fields.get("Websites").value[0].value == "https://www.contoso.com/" # The phone number values are not getting normalized to a phone number type. Just assert on text. assert len(business_card.fields.get("MobilePhones").value) == 1 assert business_card.fields.get("MobilePhones").value[0].content == "+44 (0) 7911 123456" assert len(business_card.fields.get("WorkPhones").value) == 1 assert business_card.fields.get("WorkPhones").value[0].content == "+44 (0) 20 9876 5432" assert len(business_card.fields.get("Faxes").value) == 1 assert business_card.fields.get("Faxes").value[0].content == "+44 (0) 20 6789 2345" assert len(business_card.fields.get("Addresses").value) == 1 assert business_card.fields.get("Addresses").value[0].value == "2 Kingdom Street Paddington, London, W2 6BD" assert len(business_card.fields.get("CompanyNames").value) == 1 assert business_card.fields.get("CompanyNames").value[0].value == "Contoso" return {}
async def test_receipt_url_include_field_elements(self, client): set_bodiless_matcher() async with client: poller = await client.begin_recognize_receipts_from_url( self.receipt_url_jpg, include_field_elements=True ) result = await poller.result() assert len(result) == 1 receipt = result[0] self.assertFormPagesHasValues(receipt.pages) for name, field in receipt.fields.items(): if field.value_type not in ["list", "dictionary"] and name != "ReceiptType": # receipt cases where value_data is None self.assertFieldElementsHasValues(field.value_data.field_elements, receipt.page_range.first_page_number) assert receipt.fields.get("MerchantAddress").value, '123 Main Street Redmond == WA 98052' assert receipt.fields.get("MerchantName").value == 'Contoso' assert receipt.fields.get("MerchantPhoneNumber").value == '+19876543210' assert receipt.fields.get("Subtotal").value == 11.7 assert receipt.fields.get("Tax").value == 1.17 assert receipt.fields.get("Tip").value == 1.63 assert receipt.fields.get("Total").value == 14.5 assert receipt.fields.get("TransactionDate").value == date(year=2019, month=6, day=10) assert receipt.fields.get("TransactionTime").value == time(hour=13, minute=59, second=0) assert receipt.page_range.first_page_number == 1 assert receipt.page_range.last_page_number == 1 receipt_type = receipt.fields.get("ReceiptType") assert receipt_type.confidence is not None assert receipt_type.value == 'Itemized' self.assertReceiptItemsHasValues(receipt.fields["Items"].value, receipt.page_range.first_page_number, True)
async def test_receipt_url_transform_png(self, client): set_bodiless_matcher() responses = [] def callback(raw_response, _, headers): analyze_result = client._deserialize(AnalyzeOperationResult, raw_response) extracted_receipt = prepare_prebuilt_models(analyze_result) responses.append(analyze_result) responses.append(extracted_receipt) async with client: poller = await client.begin_recognize_receipts_from_url( self.receipt_url_png, include_field_elements=True, cls=callback ) result = await poller.result() raw_response = responses[0] returned_model = responses[1] receipt = returned_model[0] actual = raw_response.analyze_result.document_results[0].fields read_results = raw_response.analyze_result.read_results document_results = raw_response.analyze_result.document_results # check dict values self.assertFormFieldsTransformCorrect(receipt.fields, actual, read_results) # check page range assert receipt.page_range.first_page_number == document_results[0].page_range[0] assert receipt.page_range.last_page_number == document_results[0].page_range[1] # Check page metadata self.assertFormPagesTransformCorrect(receipt.pages, read_results)
async def test_batch_insert_merge(self, tables_storage_account_name, tables_primary_storage_account_key): set_bodiless_matcher() # Arrange await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) try: # Act entity = TableEntity() entity['PartitionKey'] = '001' entity['RowKey'] = 'batch_insert_merge' entity['test'] = True entity['test2'] = 'value' entity['test3'] = 3 entity['test4'] = EntityProperty(1234567890, EdmType.INT32) entity['test5'] = datetime.utcnow() batch = [('upsert', entity, {'mode': UpdateMode.MERGE})] transaction_result = await self.table.submit_transaction(batch) # Assert self._assert_valid_batch_transaction(transaction_result, 1) assert 'etag' in transaction_result[0] entity = await self.table.get_entity('001', 'batch_insert_merge') assert entity is not None assert 'value' == entity['test2'] assert 1234567890 == entity['test4'] finally: await self._tear_down()
async def test_receipt_bad_url(self, client): set_bodiless_matcher() with pytest.raises(HttpResponseError): async with client: poller = await client.begin_analyze_document_from_url( "prebuilt-receipt", "https://badurl.jpg") result = await poller.result()
async def test_training_with_files_filter_v21( self, client, formrecognizer_storage_container_sas_url_v2, **kwargs): set_bodiless_matcher() async with client: poller = await client.begin_training( training_files_url=formrecognizer_storage_container_sas_url_v2, use_training_labels=False, include_subfolders=True) model = await poller.result() assert len(model.training_documents) == 6 assert model.training_documents[ -1].name == "subfolder/Form_6.jpg" # we traversed subfolders poller = await client.begin_training( formrecognizer_storage_container_sas_url_v2, use_training_labels=False, prefix="subfolder", include_subfolders=True) model = await poller.result() assert len(model.training_documents) == 1 assert model.training_documents[ 0].name == "subfolder/Form_6.jpg" # we filtered for only subfolders with pytest.raises(HttpResponseError) as e: poller = await client.begin_training( training_files_url= formrecognizer_storage_container_sas_url_v2, use_training_labels=False, prefix="xxx") model = await poller.result() assert e.value.error.code assert e.value.error.message
async def test_receipt_url_png(self, client): set_bodiless_matcher() async with client: poller = await client.begin_analyze_document_from_url( "prebuilt-receipt", self.receipt_url_png) result = await poller.result() assert len(result.documents) == 1 receipt = result.documents[0] assert receipt.fields.get( "MerchantAddress").value, '123 Main Street Redmond == WA 98052' assert receipt.fields.get("MerchantName").value == 'Contoso' assert receipt.fields.get("Subtotal").value == 1098.99 assert receipt.fields.get("Tax").value == 104.4 assert receipt.fields.get("Total").value == 1203.39 assert receipt.fields.get("TransactionDate").value == date(year=2019, month=6, day=10) assert receipt.fields.get("TransactionTime").value == time(hour=13, minute=59, second=0) receipt_type = receipt.fields.get("ReceiptType") assert receipt_type.confidence is not None assert receipt_type.value == 'Itemized' assert len(result.pages) == 1
async def test_compose_model_v21( self, client, formrecognizer_storage_container_sas_url_v2, **kwargs): set_bodiless_matcher() async with client: poller = await client.begin_training( formrecognizer_storage_container_sas_url_v2, use_training_labels=True) model_1 = await poller.result() poller = await client.begin_training( formrecognizer_storage_container_sas_url_v2, use_training_labels=True, model_name="second-labeled-model") model_2 = await poller.result() poller = await client.begin_create_composed_model( [model_1.model_id, model_2.model_id], model_name="my composed model") composed_model = await poller.result() composed_model_dict = composed_model.to_dict() composed_model = CustomFormModel.from_dict(composed_model_dict) self.assertComposedModelV2HasValues(composed_model, model_1, model_2)
async def test_custom_form_multipage_unlabeled( self, client, formrecognizer_multipage_storage_container_sas_url_v2, **kwargs): set_bodiless_matcher() fr_client = client.get_form_recognizer_client() blob_sas_url = _get_blob_url( formrecognizer_multipage_storage_container_sas_url_v2, "multipage-training-data", "multipage_invoice1.pdf") async with client: training_poller = await client.begin_training( formrecognizer_multipage_storage_container_sas_url_v2, use_training_labels=False) model = await training_poller.result() async with fr_client: poller = await fr_client.begin_recognize_custom_forms_from_url( model.model_id, blob_sas_url, ) forms = await poller.result() for form in forms: if form.form_type is None: continue # blank page assert form.form_type == "form-0" self.assertUnlabeledRecognizedFormHasValues(form, model)
async def test_batch_different_partition_operations_fail( self, tables_cosmos_account_name, tables_primary_cosmos_account_key): set_bodiless_matcher() # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key, url="cosmos") try: entity = self._create_random_entity_dict('001', 'batch_negative_1') await self.table.create_entity(entity) # Act batch = [] entity = self._create_updated_entity_dict('001', 'batch_negative_1') batch.append(('update', entity.copy())) entity = self._create_random_entity_dict('002', 'batch_negative_1') batch.append(('update', entity.copy(), { 'mode': UpdateMode.REPLACE })) # Assert with pytest.raises(ValueError): await self.table.submit_transaction(batch) finally: await self._tear_down()
def test_build_model_nested_schema_transform( self, client, formrecognizer_table_variable_rows_container_sas_url, **kwargs): set_bodiless_matcher() raw_response = [] def callback(response, _, headers): op_response = client._deserialize(GetOperationResponse, response) model_info = client._deserialize(ModelInfo, op_response.result) document_model = DocumentModel._from_generated(model_info) raw_response.append(model_info) raw_response.append(document_model) poller = client.begin_build_model( formrecognizer_table_variable_rows_container_sas_url, cls=callback) model = poller.result() raw_model = raw_response[0] document_model = raw_response[1] self.assertModelTransformCorrect(document_model, raw_model) document_model_dict = document_model.to_dict() document_model_from_dict = _models.DocumentModel.from_dict( document_model_dict) assert document_model_from_dict.model_id == document_model.model_id self.assertModelTransformCorrect(document_model_from_dict, raw_model)
async def test_async_batch_inserts(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): set_bodiless_matcher() # Arrange await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key, url="cosmos") try: # Act transaction_count = 10 async def generate_entities(count): for i in range(count): yield ("upsert", { 'PartitionKey': 'async_inserts', 'RowKey': str(i) }) batch = generate_entities(transaction_count) transaction_result = await self.table.submit_transaction(batch) # Assert self._assert_valid_batch_transaction(transaction_result, transaction_count) assert 'etag' in transaction_result[0] entities = self.table.query_entities( "PartitionKey eq 'async_inserts'") entities = [e async for e in entities] # Assert assert len(entities) == transaction_count finally: await self._tear_down()
def test_build_model_azure_blob_path_filter( self, client, formrecognizer_storage_container_sas_url, **kwargs): set_bodiless_matcher() with pytest.raises(HttpResponseError) as e: poller = client.begin_build_model( formrecognizer_storage_container_sas_url, prefix="subfolder") model = poller.result()
def test_batch_update_if_match(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): set_bodiless_matcher() # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key, url="cosmos") try: entity = self._create_random_entity_dict() resp = self.table.create_entity(entity=entity) etag = resp['etag'] # Act sent_entity = self._create_updated_entity_dict(entity['PartitionKey'], entity['RowKey']) batch = [( 'update', sent_entity, {'mode': UpdateMode.REPLACE, 'etag': etag, 'match_condition':MatchConditions.IfNotModified, 'mode':UpdateMode.REPLACE} )] transaction_result = self.table.submit_transaction(batch) # Assert self._assert_valid_batch_transaction(transaction_result, 1) assert 'etag' in transaction_result[0] entity = self.table.get_entity(partition_key=entity['PartitionKey'], row_key=entity['RowKey']) self._assert_updated_entity(entity) finally: self._tear_down()
def test_build_model_encoded_url(self, client): set_bodiless_matcher() with pytest.raises(HttpResponseError): poller = client.begin_build_model( source="https://fakeuri.com/blank%20space") assert "https://fakeuri.com/blank%20space" in poller._polling_method._initial_response.http_request.body poller.wait()
def test_batch_delete(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): set_bodiless_matcher() # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key, url="cosmos") try: # Act entity = TableEntity() entity['PartitionKey'] = u'001' entity['RowKey'] = u'batch_delete' entity['test'] = EntityProperty(True, EdmType.BOOLEAN) entity['test2'] = u'value' entity['test3'] = 3 entity['test4'] = EntityProperty(1234567890, EdmType.INT32) entity['test5'] = datetime.utcnow() self.table.create_entity(entity) entity = self.table.get_entity(partition_key=u'001', row_key=u'batch_delete') assert 3 == entity['test3'] batch = [('delete', entity)] transaction_result = self.table.submit_transaction(batch) # Assert self._assert_valid_batch_transaction(transaction_result, 1) assert 'etag' not in transaction_result[0] with pytest.raises(ResourceNotFoundError): entity = self.table.get_entity(partition_key=entity['PartitionKey'], row_key=entity['RowKey']) finally: self._tear_down()
def test_build_model_auth_bad_key(self, formrecognizer_test_endpoint, formrecognizer_test_api_key, **kwargs): set_bodiless_matcher() client = DocumentModelAdministrationClient( formrecognizer_test_endpoint, AzureKeyCredential("xxxx")) with pytest.raises(ClientAuthenticationError): poller = client.begin_build_model("xx")
def test_batch_insert(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): set_bodiless_matcher() # Arrange self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key, url="cosmos") try: # Act entity = TableEntity() entity['PartitionKey'] = '001' entity['RowKey'] = 'batch_insert_replace' entity['test'] = True entity['test2'] = 'value' entity['test3'] = 3 entity['test4'] = EntityProperty(1234567890, EdmType.INT32) entity['test5'] = datetime.utcnow() batch = [('upsert', entity)] transaction_result = self.table.submit_transaction(batch) # Assert self._assert_valid_batch_transaction(transaction_result, 1) assert 'etag' in transaction_result[0] entity = self.table.get_entity('001', 'batch_insert_replace') assert entity is not None assert 'value' == entity['test2'] assert 1234567890 == entity['test4'] finally: self._tear_down()
async def test_content_url_auth_bad_key(self, formrecognizer_test_endpoint, formrecognizer_test_api_key, **kwargs): set_bodiless_matcher() client = FormRecognizerClient(formrecognizer_test_endpoint, AzureKeyCredential("xxxx")) with pytest.raises(ClientAuthenticationError): async with client: poller = await client.begin_recognize_content_from_url(self.invoice_url_pdf) result = await poller.result()