Python azure.common.AzureHttpError() Examples

The following are 30 code examples of azure.common.AzureHttpError(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module azure.common , or try the search function .
Example #1
Source File: test_page_blob.py    From azure-storage-python with MIT License 6 votes vote down vote up
def test_update_page_from_url_with_source_if_match(self):
        # Arrange
        dest_blob_name = self.get_resource_name('destblob')
        self.bs.create_blob(self.container_name, dest_blob_name, SOURCE_BLOB_SIZE)
        src_blob_resource_properties = self.bs.get_blob_properties(self.container_name,
                                                                   self.source_blob_name).properties

        # Act part 1: make update page from url calls
        resp = self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                            end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                            source_range_start=0, source_if_match=src_blob_resource_properties.etag)
        self.assertIsNotNone(resp.etag)
        self.assertIsNotNone(resp.last_modified)

        # Assert the destination blob is constructed correctly
        blob = self.bs.get_blob_properties(self.container_name, dest_blob_name)
        self.assertBlobEqual(self.container_name, dest_blob_name, self.source_blob_data)
        self.assertEqual(blob.properties.etag, resp.etag)
        self.assertEqual(blob.properties.last_modified, resp.last_modified)

        # Act part 2: put block from url with failing condition
        with self.assertRaises(AzureHttpError):
            self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                         end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                         source_range_start=0, source_if_match='0x111111111111111') 
Example #2
Source File: test_block_blob_sync_copy.py    From azure-storage-python with MIT License 6 votes vote down vote up
def test_put_block_from_url_and_validate_content_md5(self):
        # Arrange
        dest_blob_name = self.get_resource_name('destblob')
        src_md5 = _get_content_md5(self.source_blob_data)

        # Act part 1: put block from url with md5 validation
        self.bs.put_block_from_url(self.container_name, dest_blob_name, self.source_blob_url,
                                   block_id=1, source_content_md5=src_md5)

        # Assert block was staged
        block_list = self.bs.get_block_list(self.container_name, dest_blob_name, None, 'all')
        self.assertEqual(len(block_list.uncommitted_blocks), 1)
        self.assertEqual(len(block_list.committed_blocks), 0)

        # Act part 2: put block from url with wrong md5
        with self.assertRaises(AzureHttpError):
            self.bs.put_block_from_url(self.container_name, dest_blob_name, self.source_blob_url,
                                       block_id=2, source_content_md5=_get_content_md5(b"POTATO"))

        # Assert block was not staged
        block_list = self.bs.get_block_list(self.container_name, dest_blob_name, None, 'all')
        self.assertEqual(len(block_list.uncommitted_blocks), 1)
        self.assertEqual(len(block_list.committed_blocks), 0) 
Example #3
Source File: test_block_blob.py    From azure-storage-python with MIT License 6 votes vote down vote up
def test_put_block_list_invalid_block_id(self):
        # Arrange
        blob_name = self._get_blob_reference()
        self.bs.put_block(self.container_name, blob_name, b'AAA', '1')
        self.bs.put_block(self.container_name, blob_name, b'BBB', '2')
        self.bs.put_block(self.container_name, blob_name, b'CCC', '3')

        # Act
        try:
            block_list = [ BlobBlock(id='1'), BlobBlock(id='2'), BlobBlock(id='4')]
            self.bs.put_block_list(self.container_name, blob_name, block_list)
            self.fail()
        except AzureHttpError as e:
            self.assertGreaterEqual(str(e).find('specified block list is invalid'), 0)

        # Assert 
Example #4
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 6 votes vote down vote up
def test_put_block_list_with_if_modified_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'')
        self.bs.put_block(self.container_name, 'blob1', b'AAA', '1')
        self.bs.put_block(self.container_name, 'blob1', b'BBB', '2')
        self.bs.put_block(self.container_name, 'blob1', b'CCC', '3')
        test_datetime = (datetime.datetime.utcnow() +
                         datetime.timedelta(minutes=15))

        # Act
        with self.assertRaises(AzureHttpError):
            self.bs.put_block_list(
                self.container_name, 'blob1', [BlobBlock(id='1'), BlobBlock(id='2'), BlobBlock(id='3')],
                if_modified_since=test_datetime)

        # Assert 
Example #5
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 6 votes vote down vote up
def test_put_block_list_with_if_unmodified_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'')
        self.bs.put_block(self.container_name, 'blob1', b'AAA', '1')
        self.bs.put_block(self.container_name, 'blob1', b'BBB', '2')
        self.bs.put_block(self.container_name, 'blob1', b'CCC', '3')
        test_datetime = (datetime.datetime.utcnow() -
                         datetime.timedelta(minutes=15))

        # Act
        with self.assertRaises(AzureHttpError):
            self.bs.put_block_list(
                self.container_name, 'blob1', [BlobBlock(id='1'), BlobBlock(id='2'), BlobBlock(id='3')],
                if_unmodified_since=test_datetime)

        # Assert 
Example #6
Source File: test_page_blob.py    From azure-storage-python with MIT License 6 votes vote down vote up
def test_update_page_from_url_and_validate_content_md5(self):
        # Arrange
        src_md5 = _get_content_md5(self.source_blob_data)
        dest_blob_name = self.get_resource_name('destblob')
        self.bs.create_blob(self.container_name, dest_blob_name, SOURCE_BLOB_SIZE)

        # Act part 1: make update page from url calls with correct md5
        resp = self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                            end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                            source_range_start=0, source_content_md5=src_md5)

        self.assertIsNotNone(resp.etag)
        self.assertIsNotNone(resp.last_modified)

        # Assert the destination blob is constructed correctly
        blob = self.bs.get_blob_properties(self.container_name, dest_blob_name)
        self.assertBlobEqual(self.container_name, dest_blob_name, self.source_blob_data)
        self.assertEqual(blob.properties.etag, resp.etag)
        self.assertEqual(blob.properties.last_modified, resp.last_modified)

        # Act part 2: put block from url with wrong md5
        with self.assertRaises(AzureHttpError):
            self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                         end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                         source_range_start=0, source_content_md5=_get_content_md5(b"POTATO")) 
Example #7
Source File: test_page_blob.py    From azure-storage-python with MIT License 6 votes vote down vote up
def test_update_page_from_url_with_sequence_number_eq(self):
        # Arrange
        start_sequence = 10
        dest_blob_name = self.get_resource_name('destblob')
        self.bs.create_blob(self.container_name, dest_blob_name, SOURCE_BLOB_SIZE, sequence_number=start_sequence)

        # Act part 1: make update page from url calls
        resp = self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                            end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                            source_range_start=0, if_sequence_number_eq=start_sequence)
        self.assertIsNotNone(resp.etag)
        self.assertIsNotNone(resp.last_modified)

        # Assert the destination blob is constructed correctly
        blob = self.bs.get_blob_properties(self.container_name, dest_blob_name)
        self.assertBlobEqual(self.container_name, dest_blob_name, self.source_blob_data)
        self.assertEqual(blob.properties.etag, resp.etag)
        self.assertEqual(blob.properties.last_modified, resp.last_modified)

        # Act part 2: put block from url with failing condition
        with self.assertRaises(AzureHttpError):
            self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                         end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                         source_range_start=0, if_sequence_number_eq=start_sequence + 1) 
Example #8
Source File: test_page_blob.py    From azure-storage-python with MIT License 6 votes vote down vote up
def test_update_page_from_url_with_sequence_number_lt(self):
        # Arrange
        start_sequence = 10
        dest_blob_name = self.get_resource_name('destblob')
        self.bs.create_blob(self.container_name, dest_blob_name, SOURCE_BLOB_SIZE, sequence_number=start_sequence)

        # Act part 1: make update page from url calls
        resp = self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                            end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                            source_range_start=0, if_sequence_number_lt=start_sequence + 1)
        self.assertIsNotNone(resp.etag)
        self.assertIsNotNone(resp.last_modified)

        # Assert the destination blob is constructed correctly
        blob = self.bs.get_blob_properties(self.container_name, dest_blob_name)
        self.assertBlobEqual(self.container_name, dest_blob_name, self.source_blob_data)
        self.assertEqual(blob.properties.etag, resp.etag)
        self.assertEqual(blob.properties.last_modified, resp.last_modified)

        # Act part 2: put block from url with failing condition
        with self.assertRaises(AzureHttpError):
            self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                         end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                         source_range_start=0, if_sequence_number_lt=start_sequence) 
Example #9
Source File: azure_store.py    From polystores with MIT License 6 votes vote down vote up
def download_file(self, blob, local_path, container_name=None, use_basename=True):
        """
        Downloads a file from Google Cloud Storage.

        Args:
            blob: `str`. blob to download.
            local_path: `str`. the path to download to.
            container_name: `str`. the name of the container.
            use_basename: `bool`. whether or not to use the basename of the blob.
        """
        if not container_name:
            container_name, _, blob = self.parse_wasbs_url(blob)

        local_path = os.path.abspath(local_path)

        if use_basename:
            local_path = append_basename(local_path, blob)

        check_dirname_exists(local_path)

        try:
            self.connection.get_blob_to_path(container_name, blob, local_path)
        except AzureHttpError as e:
            raise PolyaxonStoresException(e) 
Example #10
Source File: azure_store.py    From polystores with MIT License 6 votes vote down vote up
def check_blob(self, blob, container_name=None):
        """
        Checks if a blob exists.

        Args:
            blob: `str`. Name of existing blob.
            container_name: `str`. Name of existing container.

        Returns:
            bool
        """
        if not container_name:
            container_name, _, blob = self.parse_wasbs_url(blob)
        try:
            return self.connection.get_blob_properties(
                container_name,
                blob
            )
        except AzureHttpError:
            return None 
Example #11
Source File: test_page_blob.py    From azure-storage-python with MIT License 6 votes vote down vote up
def test_update_page_from_url_with_if_none_match(self):
        # Arrange
        dest_blob_name = self.get_resource_name('destblob')
        self.bs.create_blob(self.container_name, dest_blob_name, SOURCE_BLOB_SIZE)

        # Act part 1: make update page from url calls
        resp = self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                            end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                            source_range_start=0, if_none_match='0x111111111111111')
        self.assertIsNotNone(resp.etag)
        self.assertIsNotNone(resp.last_modified)

        # Assert the destination blob is constructed correctly
        blob = self.bs.get_blob_properties(self.container_name, dest_blob_name)
        self.assertBlobEqual(self.container_name, dest_blob_name, self.source_blob_data)
        self.assertEqual(blob.properties.etag, resp.etag)
        self.assertEqual(blob.properties.last_modified, resp.last_modified)

        # Act part 2: put block from url with failing condition
        with self.assertRaises(AzureHttpError):
            self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                         end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                         source_range_start=0, if_none_match=blob.properties.etag) 
Example #12
Source File: wasb_task_handler.py    From airflow with Apache License 2.0 6 votes vote down vote up
def wasb_read(self, remote_log_location, return_error=False):
        """
        Returns the log found at the remote_log_location. Returns '' if no
        logs are found or there is an error.

        :param remote_log_location: the log's location in remote storage
        :type remote_log_location: str (path)
        :param return_error: if True, returns a string error message if an
            error occurs. Otherwise returns '' when an error occurs.
        :type return_error: bool
        """
        try:
            return self.hook.read_file(self.wasb_container, remote_log_location)
        except AzureHttpError:
            msg = 'Could not read logs from {}'.format(remote_log_location)
            self.log.exception(msg)
            # return error if needed
            if return_error:
                return msg 
Example #13
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 6 votes vote down vote up
def test_get_page_ranges_iter_with_if_unmodified_fail(self):
        # Arrange
        self._create_container_and_page_blob(
            self.container_name, 'blob1', 2048)
        data = b'abcdefghijklmnop' * 32
        test_datetime = (datetime.datetime.utcnow() -
                         datetime.timedelta(minutes=15))
        self.pbs.update_page(self.container_name, 'blob1', data, 0, 511)
        self.pbs.update_page(self.container_name, 'blob1', data, 1024, 1535)

        # Act
        with self.assertRaises(AzureHttpError):
            self.pbs.get_page_ranges(self.container_name, 'blob1',
                                     if_unmodified_since=test_datetime)

        # Assert 
Example #14
Source File: test_page_blob.py    From azure-storage-python with MIT License 6 votes vote down vote up
def test_update_page_from_url_with_if_unmodified(self):
        # Arrange
        dest_blob_name = self.get_resource_name('destblob')
        resource_properties = self.bs.create_blob(self.container_name, dest_blob_name, SOURCE_BLOB_SIZE)

        # Act part 1: make update page from url calls
        resp = self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                            end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                            source_range_start=0, if_unmodified_since=resource_properties.last_modified)
        self.assertIsNotNone(resp.etag)
        self.assertIsNotNone(resp.last_modified)

        # Assert the destination blob is constructed correctly
        blob = self.bs.get_blob_properties(self.container_name, dest_blob_name)
        self.assertBlobEqual(self.container_name, dest_blob_name, self.source_blob_data)
        self.assertEqual(blob.properties.etag, resp.etag)
        self.assertEqual(blob.properties.last_modified, resp.last_modified)

        # Act part 2: put block from url with failing condition
        with self.assertRaises(AzureHttpError):
            self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                         end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                         source_range_start=0,
                                         if_unmodified_since=resource_properties.last_modified - timedelta(
                                             minutes=15)) 
Example #15
Source File: test_page_blob.py    From azure-storage-python with MIT License 6 votes vote down vote up
def test_update_page_from_url_with_if_match(self):
        # Arrange
        dest_blob_name = self.get_resource_name('destblob')
        resource_properties = self.bs.create_blob(self.container_name, dest_blob_name, SOURCE_BLOB_SIZE)

        # Act part 1: make update page from url calls
        resp = self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                            end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                            source_range_start=0, if_match=resource_properties.etag)
        self.assertIsNotNone(resp.etag)
        self.assertIsNotNone(resp.last_modified)

        # Assert the destination blob is constructed correctly
        blob = self.bs.get_blob_properties(self.container_name, dest_blob_name)
        self.assertBlobEqual(self.container_name, dest_blob_name, self.source_blob_data)
        self.assertEqual(blob.properties.etag, resp.etag)
        self.assertEqual(blob.properties.last_modified, resp.last_modified)

        # Act part 2: put block from url with failing condition
        with self.assertRaises(AzureHttpError):
            self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                         end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                         source_range_start=0, if_match='0x111111111111111') 
Example #16
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 5 votes vote down vote up
def test_get_blob_metadata_with_if_none_match_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'hello world')
        etag = self.bs.get_blob_properties(self.container_name, 'blob1').properties.etag

        # Act
        with self.assertRaises(AzureHttpError):
            self.bs.get_blob_metadata(self.container_name, 'blob1',
                                      if_none_match=etag)

        # Assert 
Example #17
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 5 votes vote down vote up
def test_delete_blob_with_if_modified_fail(self):
        # Arrange
        test_datetime = (datetime.datetime.utcnow() +
                         datetime.timedelta(minutes=15))
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'hello world')

        # Act
        with self.assertRaises(AzureHttpError):
            self.bs.delete_blob(self.container_name, 'blob1',
                                if_modified_since=test_datetime)

        # Assert 
Example #18
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 5 votes vote down vote up
def test_set_blob_metadata_with_if_none_match_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'hello world')
        etag = self.bs.get_blob_properties(self.container_name, 'blob1').properties.etag

        # Act
        with self.assertRaises(AzureHttpError):
            metadata = {'hello': 'world', 'number': '42'}
            self.bs.set_blob_metadata(self.container_name, 'blob1', metadata, if_none_match=etag)

        # Assert 
Example #19
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 5 votes vote down vote up
def test_update_page_with_if_modified_fail(self):
        # Arrange
        self._create_container_and_page_blob(
            self.container_name, 'blob1', 1024)
        test_datetime = (datetime.datetime.utcnow() +
                         datetime.timedelta(minutes=15))
        data = b'abcdefghijklmnop' * 32

        # Act
        with self.assertRaises(AzureHttpError):
            self.pbs.update_page(self.container_name, 'blob1', data, 0, 511, if_modified_since=test_datetime)

        # Assert 
Example #20
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 5 votes vote down vote up
def test_set_blob_metadata_with_if_match_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'hello world')

        # Act
        with self.assertRaises(AzureHttpError):
            metadata = {'hello': 'world', 'number': '42'}
            self.bs.set_blob_metadata(self.container_name, 'blob1', metadata, if_match='0x111111111111111')

        # Assert 
Example #21
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 5 votes vote down vote up
def test_set_blob_metadata_with_if_unmodified_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'hello world')
        test_datetime = (datetime.datetime.utcnow() -
                         datetime.timedelta(minutes=15))

        # Act
        with self.assertRaises(AzureHttpError):
            metadata = {'hello': 'world', 'number': '42'}
            self.bs.set_blob_metadata(self.container_name, 'blob1', metadata, if_unmodified_since=test_datetime)

        # Assert 
Example #22
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 5 votes vote down vote up
def test_snapshot_blob_with_if_modified_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'hello world')
        test_datetime = (datetime.datetime.utcnow() +
                         datetime.timedelta(minutes=15))

        # Act
        with self.assertRaises(AzureHttpError):
            self.bs.snapshot_blob(self.container_name, 'blob1',
                                  if_modified_since=test_datetime)

        # Assert 
Example #23
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 5 votes vote down vote up
def test_get_blob_metadata_with_if_match_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'hello world')

        # Act
        with self.assertRaises(AzureHttpError):
            self.bs.get_blob_metadata(self.container_name, 'blob1',
                                      if_match='0x111111111111111')

        # Assert 
Example #24
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 5 votes vote down vote up
def test_get_blob_metadata_with_if_unmodified_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'hello world')
        test_datetime = (datetime.datetime.utcnow() -
                         datetime.timedelta(minutes=15))

        # Act
        with self.assertRaises(AzureHttpError):
            self.bs.get_blob_metadata(self.container_name, 'blob1',
                                      if_unmodified_since=test_datetime)

        # Assert 
Example #25
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 5 votes vote down vote up
def test_get_blob_metadata_with_if_modified_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'hello world')
        test_datetime = (datetime.datetime.utcnow() +
                         datetime.timedelta(minutes=15))

        # Act
        with self.assertRaises(AzureHttpError):
            self.bs.get_blob_metadata(self.container_name, 'blob1',
                                      if_modified_since=test_datetime)

        # Assert 
Example #26
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 5 votes vote down vote up
def test_get_blob_properties_with_if_none_match_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'hello world')
        etag = self.bs.get_blob_properties(self.container_name, 'blob1').properties.etag

        # Act
        with self.assertRaises(AzureHttpError):
            self.bs.get_blob_properties(self.container_name, 'blob1',
                                        if_none_match=etag)

        # Assert 
Example #27
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 5 votes vote down vote up
def test_get_blob_properties_with_if_unmodified_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'hello world')
        test_datetime = (datetime.datetime.utcnow() -
                         datetime.timedelta(minutes=15))
        # Act
        with self.assertRaises(AzureHttpError):
            self.bs.get_blob_properties(self.container_name, 'blob1',
                                        if_unmodified_since=test_datetime)

        # Assert 
Example #28
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 5 votes vote down vote up
def test_get_blob_properties_with_if_modified_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'hello world')
        test_datetime = (datetime.datetime.utcnow() +
                         datetime.timedelta(minutes=15))
        # Act
        with self.assertRaises(AzureHttpError):
            self.bs.get_blob_properties(self.container_name, 'blob1',
                                        if_modified_since=test_datetime)

        # Assert 
Example #29
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 5 votes vote down vote up
def test_set_blob_properties_with_if_none_match_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'hello world')
        etag = self.bs.get_blob_properties(self.container_name, 'blob1').properties.etag

        # Act
        with self.assertRaises(AzureHttpError):
            content_settings = ContentSettings(
                content_language='spanish',
                content_disposition='inline')
            self.bs.set_blob_properties(self.container_name, 'blob1', content_settings, if_none_match=etag)

        # Assert 
Example #30
Source File: test_blob_access_conditions.py    From azure-storage-python with MIT License 5 votes vote down vote up
def test_set_blob_properties_with_if_match_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'hello world')

        # Act
        with self.assertRaises(AzureHttpError):
            content_settings = ContentSettings(
                content_language='spanish',
                content_disposition='inline')
            self.bs.set_blob_properties(self.container_name, 'blob1', content_settings, if_match='0x111111111111111')

        # Assert