def test_custom_form_submodel_to_dict(self): model = _models.CustomFormSubmodel( model_id="1234", form_type="submodel", accuracy=0.98, fields={ "example": _models.CustomFormModelField( label="field_label", name="field", accuracy=0.98, ) } ) d = model.to_dict() final = { "model_id": "1234", "form_type": "submodel", "accuracy": 0.98, "fields": { "example": { "label": "field_label", "name": "field", "accuracy": 0.98, } } } assert d == final
def custom_form_sub_model(custom_form_model_field): model = _models.CustomFormSubmodel( accuracy=0.99, fields={"name": custom_form_model_field[0]}, form_type="Itemized") model_repr = "CustomFormSubmodel(accuracy=0.99, fields={{'name': {}}}, form_type=Itemized)".format( custom_form_model_field[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