當前位置: 首頁>>代碼示例>>Python>>正文


Python TableService.cancel_batch方法代碼示例

本文整理匯總了Python中azure.storage.TableService.cancel_batch方法的典型用法代碼示例。如果您正苦於以下問題:Python TableService.cancel_batch方法的具體用法?Python TableService.cancel_batch怎麽用?Python TableService.cancel_batch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在azure.storage.TableService的用法示例。


在下文中一共展示了TableService.cancel_batch方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TableServiceTest

# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import cancel_batch [as 別名]

#.........這裏部分代碼省略.........
        self.ts.insert_or_merge_entity(
            self.table_name, entity.PartitionKey, entity.RowKey, entity)
        self.ts.commit_batch()

        # Assert
        entities = self.ts.query_entities(
            self.table_name, "PartitionKey eq '003'", '')
        self.assertEqual(5, len(entities))

    def test_batch_same_row_operations_fail(self):
        # Arrange
        self._create_table(self.table_name)
        entity = self._create_default_entity_dict('001', 'batch_negative_1')
        self.ts.insert_entity(self.table_name, entity)

        # Act
        with self.assertRaises(WindowsAzureError):
            self.ts.begin_batch()

            entity = self._create_updated_entity_dict(
                '001', 'batch_negative_1')
            self.ts.update_entity(
                self.table_name,
                entity['PartitionKey'],
                entity['RowKey'], entity)

            entity = self._create_default_entity_dict(
                '001', 'batch_negative_1')
            self.ts.merge_entity(
                self.table_name,
                entity['PartitionKey'],
                entity['RowKey'], entity)

        self.ts.cancel_batch()

        # Assert

    def test_batch_different_partition_operations_fail(self):
        # Arrange
        self._create_table(self.table_name)
        entity = self._create_default_entity_dict('001', 'batch_negative_1')
        self.ts.insert_entity(self.table_name, entity)

        # Act
        with self.assertRaises(WindowsAzureError):
            self.ts.begin_batch()

            entity = self._create_updated_entity_dict(
                '001', 'batch_negative_1')
            self.ts.update_entity(
                self.table_name, entity['PartitionKey'], entity['RowKey'],
                entity)

            entity = self._create_default_entity_dict(
                '002', 'batch_negative_1')
            self.ts.insert_entity(self.table_name, entity)

        self.ts.cancel_batch()

        # Assert

    def test_batch_different_table_operations_fail(self):
        # Arrange
        other_table_name = self.table_name + 'other'
        self.additional_table_names = [other_table_name]
        self._create_table(self.table_name)
開發者ID:algaruda,項目名稱:azure-sdk-for-python,代碼行數:70,代碼來源:test_tableservice.py

示例2: TableServiceTest

# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import cancel_batch [as 別名]

#.........這裏部分代碼省略.........
        entity.RowKey = 'batch_all_operations_together-2'
        entity.test3 = 10
        self.tc.update_entity(self.table_name, entity.PartitionKey, entity.RowKey, entity)
        entity.RowKey = 'batch_all_operations_together-3'
        entity.test3 = 100
        self.tc.merge_entity(self.table_name, entity.PartitionKey, entity.RowKey, entity)
        entity.RowKey = 'batch_all_operations_together-4'
        entity.test3 = 10
        self.tc.insert_or_replace_entity(self.table_name, entity.PartitionKey, entity.RowKey, entity)
        entity.RowKey = 'batch_all_operations_together-5'
        self.tc.insert_or_merge_entity(self.table_name, entity.PartitionKey, entity.RowKey, entity)
        self.tc.commit_batch()

        # Assert
        entities = self.tc.query_entities(self.table_name, "PartitionKey eq '003'", '')
        self.assertEqual(5, len(entities))

    def test_batch_same_row_operations_fail(self):
        # Arrange
        self._create_table(self.table_name)
        entity = self._create_default_entity_dict('001', 'batch_negative_1')
        self.tc.insert_entity(self.table_name, entity)

        # Act
        with self.assertRaises(WindowsAzureError):
            self.tc.begin_batch()

            entity = self._create_updated_entity_dict('001', 'batch_negative_1')
            self.tc.update_entity(self.table_name, entity['PartitionKey'], entity['RowKey'], entity)

            entity = self._create_default_entity_dict('001', 'batch_negative_1')
            self.tc.merge_entity(self.table_name, entity['PartitionKey'], entity['RowKey'], entity)

        self.tc.cancel_batch()

        # Assert

    def test_batch_different_partition_operations_fail(self):
        # Arrange
        self._create_table(self.table_name)
        entity = self._create_default_entity_dict('001', 'batch_negative_1')
        self.tc.insert_entity(self.table_name, entity)

        # Act
        with self.assertRaises(WindowsAzureError):
            self.tc.begin_batch()

            entity = self._create_updated_entity_dict('001', 'batch_negative_1')
            self.tc.update_entity(self.table_name, entity['PartitionKey'], entity['RowKey'], entity)

            entity = self._create_default_entity_dict('002', 'batch_negative_1')
            self.tc.insert_entity(self.table_name, entity) 

        self.tc.cancel_batch()

        # Assert

    def test_batch_different_table_operations_fail(self):
        # Arrange
        other_table_name = self.table_name + 'other'
        self.additional_table_names = [other_table_name]
        self._create_table(self.table_name)
        self._create_table(other_table_name)

        # Act
        with self.assertRaises(WindowsAzureError):
開發者ID:Bunkerbewohner,項目名稱:azure-sdk-for-python,代碼行數:70,代碼來源:test_tableservice.py


注:本文中的azure.storage.TableService.cancel_batch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。