def test_should_accept_document_filter(): document_filter_mock = Mock(spec=SandboxDocumentFilter) check = (SandboxDocumentTextDataCheckBuilder().with_document_filter( document_filter_mock).build()) assert check.document_filter == document_filter_mock
def test_should_allow_document_fields_set_with_dictionary(): check = (SandboxDocumentTextDataCheckBuilder().with_document_fields({ "someKey": "someValue" }).build()) assert check.result.document_fields.get("someKey") == "someValue"
def test_json_should_include_document_fields_when_set(): check = (SandboxDocumentTextDataCheckBuilder().with_document_field( "someKey", "someValue").build()) json = check.to_json() assert (json.get("result").to_json().get("document_fields").get("someKey") == "someValue")
def test_json_should_include_document_filter(): document_filter_mock = Mock(spec=SandboxDocumentFilter) check = (SandboxDocumentTextDataCheckBuilder().with_document_filter( document_filter_mock).build()) json = check.to_json() assert json.get("document_filter") == document_filter_mock
def doc_scan_example_snippet(): document_filter = (SandboxDocumentFilterBuilder().with_country_code( "GBR").with_document_type("PASSPORT").build()) response_config = (ResponseConfigBuilder().with_check_reports( (SandboxCheckReportsBuilder( ).with_async_report_delay(10).with_document_authenticity_check( (SandboxDocumentAuthenticityCheckBuilder().with_breakdown( (SandboxBreakdownBuilder().with_sub_check("security_features"). with_result("NOT_AVAILABLE").with_detail( SandboxDetail("some_detail", "some_detail_value")).build() )).with_recommendation( (SandboxRecommendationBuilder().with_value( "NOT_AVAILABLE").with_reason("PICTURE_TOO_DARK"). with_recovery_suggestion("BETTER_LIGHTING").build() )).with_document_filter(document_filter).build()) ).with_document_face_match_check( (SandboxDocumentFaceMatchCheckBuilder().with_breakdown( (SandboxBreakdownBuilder().with_sub_check("security_features"). with_result("PASS").build())).with_recommendation( (SandboxRecommendationBuilder().with_value("APPROVE"). build())).with_document_filter(document_filter).build()) ).with_document_text_data_check( (SandboxDocumentTextDataCheckBuilder().with_breakdown( (SandboxBreakdownBuilder().with_sub_check( "document_in_date").with_result("PASS").build())). with_recommendation( (SandboxRecommendationBuilder().with_value("APPROVE").build() )).with_document_filter(document_filter).with_document_field( "full_name", "John Doe").with_document_field( "nationality", "GBR").with_document_field( "date_of_birth", "1986-06-01").with_document_field( "document_number", "123456789").build())). with_liveness_check((SandboxZoomLivenessCheckBuilder().with_breakdown( (SandboxBreakdownBuilder().with_sub_check("security_features"). with_result("PASS").build())).with_recommendation( (SandboxRecommendationBuilder().with_value( "APPROVE").build())).build())).build()) ).with_task_results((SandboxTaskResultsBuilder().with_text_extraction_task( (SandboxDocumentTextDataExtractionTaskBuilder().with_document_field( "full_name", "John Doe").with_document_field( "nationality", "GBR").with_document_field( "date_of_birth", "1986-06-01").with_document_field( "document_number", "123456789").with_document_filter( document_filter).build())).build())).build()) sandbox_client_sdk_id = "YourSandboxClientSdkIdFromHub" pem_file_path = "path/to/your/pem/file.pem" doc_scan_sandbox_client = DocScanSandboxClient(sandbox_client_sdk_id, pem_file_path) doc_scan_sandbox_client.configure_session_response("yourSessionId", response_config)
def test_json_includes_recommendation(): recommendation_mock = Mock(spec=SandboxRecommendation) check = (SandboxDocumentTextDataCheckBuilder().with_recommendation( recommendation_mock).build()) json = check.to_json() assert (json.get("result").to_json().get("report").to_json().get( "recommendation") == recommendation_mock)
def test_should_accept_with_breakdowns(): breakdowns_mock = [ Mock(spec=SandboxBreakdown), Mock(spec=SandboxBreakdown) ] check = (SandboxDocumentTextDataCheckBuilder().with_breakdowns( breakdowns_mock).build()) assert check.result.report.breakdown == breakdowns_mock
def test_should_build_sandbox_document_authenticity_check(): recommendation_mock = Mock(spec=SandboxRecommendation) breakdown_mock = Mock(spec=SandboxBreakdown) check = (SandboxDocumentTextDataCheckBuilder().with_recommendation( recommendation_mock).with_breakdown(breakdown_mock).build()) assert check.result.report.recommendation is not None assert check.result.report.recommendation == recommendation_mock assert len(check.result.report.breakdown) == 1 assert check.result.report.breakdown[0] == breakdown_mock
def test_json_includes_breakdowns(): breakdowns_mock = [ Mock(spec=SandboxBreakdown), Mock(spec=SandboxBreakdown) ] check = (SandboxDocumentTextDataCheckBuilder().with_breakdowns( breakdowns_mock).build()) json = check.to_json() assert (json.get("result").to_json().get("report").to_json().get( "breakdown") == breakdowns_mock)
def test_json_should_exclude_document_fields_when_not_set(): check = SandboxDocumentTextDataCheckBuilder().build() json = check.to_json() assert json.get("result").to_json().get("document_fields") is None