async def test_get_document_analysis_client(self,
                                                formrecognizer_test_endpoint,
                                                formrecognizer_test_api_key,
                                                **kwargs):
        # this can be reverted to set_bodiless_matcher() after tests are re-recorded and don't contain these headers
        set_custom_default_matcher(
            compare_bodies=False,
            excluded_headers=
            "Authorization,Content-Length,x-ms-client-request-id,x-ms-request-id"
        )
        transport = AioHttpTransport()
        dtc = DocumentModelAdministrationClient(
            endpoint=formrecognizer_test_endpoint,
            credential=AzureKeyCredential(formrecognizer_test_api_key),
            transport=transport)

        async with dtc:
            await dtc.get_account_info()
            assert transport.session is not None
            async with dtc.get_document_analysis_client() as dac:
                assert transport.session is not None
                await (await dac.begin_analyze_document_from_url(
                    "prebuilt-receipt", self.receipt_url_jpg)).wait()
                assert dac._api_version == DocumentAnalysisApiVersion.V2022_01_30_PREVIEW
            await dtc.get_account_info()
            assert transport.session is not None
예제 #2
0
    def test_get_document_analysis_client(self, formrecognizer_test_endpoint, formrecognizer_test_api_key):
        transport = RequestsTransport()
        dtc = DocumentModelAdministrationClient(endpoint=formrecognizer_test_endpoint, credential=AzureKeyCredential(formrecognizer_test_api_key), transport=transport)

        with dtc:
            dtc.get_account_info()
            assert transport.session is not None
            with dtc.get_document_analysis_client() as dac:
                assert transport.session is not None
                dac.begin_analyze_document_from_url("prebuilt-receipt", self.receipt_url_jpg).wait()
                assert dac._api_version == DocumentAnalysisApiVersion.V2021_09_30_PREVIEW
            dtc.get_account_info()
            assert transport.session is not None