Example #1
0
    def setUp(self):
        super(StorageDirectoryTest, self).setUp()

        url = self.get_file_url()
        credential = self.get_shared_key_credential()
        self.fsc = FileServiceClient(url, credential=credential, transport=AiohttpTestTransport())
        self.share_name = self.get_resource_name('utshare')
Example #2
0
    async def _test_user_agent_custom_async(self):
        custom_app = "TestApp/v1.0"
        service = FileServiceClient(self.get_file_url(),
                                    credential=self.account_key,
                                    user_agent=custom_app,
                                    transport=AiohttpTestTransport())

        def callback1(response):
            self.assertTrue('User-Agent' in response.http_request.headers)
            self.assertEqual(
                response.http_request.headers['User-Agent'],
                "TestApp/v1.0 azsdk-python-storage-file/{} Python/{} ({})".
                format(VERSION, platform.python_version(),
                       platform.platform()))

        await service.get_service_properties(raw_response_hook=callback1)

        def callback2(response):
            self.assertTrue('User-Agent' in response.http_request.headers)
            self.assertEqual(
                response.http_request.headers['User-Agent'],
                "TestApp/v2.0 azsdk-python-storage-file/{} Python/{} ({})".
                format(VERSION, platform.python_version(),
                       platform.platform()))

        await service.get_service_properties(raw_response_hook=callback2,
                                             user_agent="TestApp/v2.0")
    def setUp(self):
        super(FileServicePropertiesTest, self).setUp()

        url = self.get_file_url()
        credential = self.get_shared_key_credential()
        self.fsc = FileServiceClient(url,
                                     credential=credential,
                                     transport=AiohttpTestTransport())
    def setUp(self):
        super(StorageShareTest, self).setUp()

        file_url = self.get_file_url()
        credentials = self.get_shared_key_credential()
        self.fsc = FileServiceClient(account_url=file_url, credential=credentials, transport=AiohttpTestTransport())
        loop = asyncio.get_event_loop()
        loop.run_until_complete(self.fsc.__aenter__())
        self.test_shares = []
    async def _test_auth_shared_key(self):
        # Instantiate a FileServiceClient using a shared access key
        # [START create_file_service_client]
        from azure.storage.file.aio import FileServiceClient
        file_service_client = FileServiceClient(
            account_url=self.url, credential=self.shared_access_key)
        # [END create_file_service_client]

        # Get account information for the File Service
        account_info = await file_service_client.get_service_properties()
        assert account_info is not None
    async def _test_user_agent_append_async(self):
        service = FileServiceClient(self.get_file_url(), credential=self.account_key, transport=AiohttpTestTransport())

        def callback(response):
            self.assertTrue('User-Agent' in response.http_request.headers)
            self.assertEqual(
                response.http_request.headers['User-Agent'],
                "azsdk-python-storage-file/{} Python/{} ({}) customer_user_agent".format(
                    VERSION,
                    platform.python_version(),
                    platform.platform()))

        custom_headers = {'User-Agent': 'customer_user_agent'}
        await service.get_service_properties(raw_response_hook=callback, headers=custom_headers)
 async def _test_transport_closed_only_once_async(self):
     if TestMode.need_recording_file(self.test_mode):
         return
     transport = AioHttpTransport()
     url = self.get_file_url()
     credential = self.get_shared_key_credential()
     prefix = TEST_SHARE_PREFIX
     share_name = self.get_resource_name(prefix)
     async with FileServiceClient(url,
                                  credential=credential,
                                  transport=transport) as fsc:
         await fsc.get_service_properties()
         assert transport.session is not None
         async with fsc.get_share_client(share_name) as fc:
             assert transport.session is not None
         await fsc.get_service_properties()
         assert transport.session is not None