def test_training_document_info_to_dict(self): model = _models.TrainingDocumentInfo( name="sample doc", status="succeeded", page_count=3, errors=[ _models.FormRecognizerError( code=404, message="error not found", ) ], model_id="1234", ) d = model.to_dict() final = { "name": "sample doc", "status": "succeeded", "page_count": 3, "errors": [ { "code": 404, "message": "error not found", } ], "model_id": "1234", } assert d == final
def training_document_info(form_recognizer_error): model = _models.TrainingDocumentInfo( document_name="document_name", status=_models.TrainingStatus.partially_succeeded, page_count=5, errors=[form_recognizer_error[0]]) model_repr = "TrainingDocumentInfo(document_name=document_name, status=partiallySucceeded, page_count=5, errors=[{}])".format( form_recognizer_error[1])[:1024] assert repr(model) == model_repr return model, model_repr
def training_document_info(form_recognizer_error): model = _models.TrainingDocumentInfo( name="name", status=_models.TrainingStatus.PARTIALLY_SUCCEEDED, page_count=5, errors=[form_recognizer_error[0]], model_id=1) model_repr = "TrainingDocumentInfo(name=name, status=partiallySucceeded, page_count=5, errors=[{}], model_id=1)".format( form_recognizer_error[1])[:1024] assert repr(model) == model_repr return model, model_repr
def test_custom_form_model_to_dict(self): model = _models.CustomFormModel( model_id="1234", status="ready", training_started_on=datetime(2021, 1, 10, 23, 55, 59, 342380), training_completed_on=datetime(2021, 1, 10, 23, 55, 59, 342380), submodels=[ _models.CustomFormSubmodel( model_id="1234", form_type="submodel", accuracy=0.98, fields={ "example": _models.CustomFormModelField( label="field_label", name="field", accuracy=0.98, ) } ) ], errors=[ _models.FormRecognizerError( code=404, message="error not found", ) ], training_documents=[ _models.TrainingDocumentInfo( name="sample doc", status="succeeded", page_count=3, errors=[ _models.FormRecognizerError( code=404, message="error not found", ) ], model_id="1234", ) ], model_name="sample model", properties=_models.CustomFormModelProperties( is_composed_model=True, ) ) d = model.to_dict() final = { "model_id": "1234", "status": "ready", "training_started_on": datetime(2021, 1, 10, 23, 55, 59, 342380), "training_completed_on": datetime(2021, 1, 10, 23, 55, 59, 342380), "submodels": [{ "model_id": "1234", "form_type": "submodel", "accuracy": 0.98, "fields": { "example": { "label": "field_label", "name": "field", "accuracy": 0.98, } } }], "errors": [ { "code": 404, "message": "error not found", } ], "training_documents": [ { "name": "sample doc", "status": "succeeded", "page_count": 3, "errors": [ { "code": 404, "message": "error not found", } ], "model_id": "1234", } ], "model_name": "sample model", "properties": { "is_composed_model": True, } } assert d == final