本文整理匯總了Python中azure.storage.TableService.merge_entity方法的典型用法代碼示例。如果您正苦於以下問題:Python TableService.merge_entity方法的具體用法?Python TableService.merge_entity怎麽用?Python TableService.merge_entity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類azure.storage.TableService
的用法示例。
在下文中一共展示了TableService.merge_entity方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TableServiceTest
# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import merge_entity [as 別名]
#.........這裏部分代碼省略.........
received_entity = self.ts.get_entity(
self.table_name, 'MyPartition', '1')
self._assert_updated_entity(received_entity)
def test_update_entity_with_if_matches(self):
# Arrange
entities = self._create_table_with_default_entities(self.table_name, 1)
# Act
sent_entity = self._create_updated_entity_dict('MyPartition', '1')
resp = self.ts.update_entity(
self.table_name,
'MyPartition', '1', sent_entity, if_match=entities[0].etag)
# Assert
self.assertIsNotNone(resp)
received_entity = self.ts.get_entity(
self.table_name, 'MyPartition', '1')
self._assert_updated_entity(received_entity)
def test_update_entity_with_if_doesnt_match(self):
# Arrange
entities = self._create_table_with_default_entities(self.table_name, 1)
# Act
sent_entity = self._create_updated_entity_dict('MyPartition', '1')
with self.assertRaises(WindowsAzureError):
self.ts.update_entity(
self.table_name, 'MyPartition', '1', sent_entity,
if_match=u'W/"datetime\'2012-06-15T22%3A51%3A44.9662825Z\'"')
# Assert
def test_insert_or_merge_entity_with_existing_entity(self):
# Arrange
self._create_table_with_default_entities(self.table_name, 1)
# Act
sent_entity = self._create_updated_entity_dict('MyPartition', '1')
resp = self.ts.insert_or_merge_entity(
self.table_name, 'MyPartition', '1', sent_entity)
# Assert
self.assertIsNotNone(resp)
received_entity = self.ts.get_entity(
self.table_name, 'MyPartition', '1')
self._assert_merged_entity(received_entity)
def test_insert_or_merge_entity_with_non_existing_entity(self):
# Arrange
self._create_table(self.table_name)
# Act
sent_entity = self._create_updated_entity_dict('MyPartition', '1')
resp = self.ts.insert_or_merge_entity(
self.table_name, 'MyPartition', '1', sent_entity)
# Assert
self.assertIsNotNone(resp)
received_entity = self.ts.get_entity(
self.table_name, 'MyPartition', '1')
self._assert_updated_entity(received_entity)
def test_insert_or_replace_entity_with_existing_entity(self):
# Arrange
self._create_table_with_default_entities(self.table_name, 1)
示例2: TableServiceTest
# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import merge_entity [as 別名]
#.........這裏部分代碼省略.........
# Act
sent_entity = self._create_updated_entity_dict('MyPartition','1')
resp = self.tc.update_entity(self.table_name, 'MyPartition', '1', sent_entity)
# Assert
self.assertIsNotNone(resp)
received_entity = self.tc.get_entity(self.table_name, 'MyPartition', '1')
self._assert_updated_entity(received_entity)
def test_update_entity_with_if_matches(self):
# Arrange
entities = self._create_table_with_default_entities(self.table_name, 1)
# Act
sent_entity = self._create_updated_entity_dict('MyPartition','1')
resp = self.tc.update_entity(self.table_name, 'MyPartition', '1', sent_entity, if_match=entities[0].etag)
# Assert
self.assertIsNotNone(resp)
received_entity = self.tc.get_entity(self.table_name, 'MyPartition', '1')
self._assert_updated_entity(received_entity)
def test_update_entity_with_if_doesnt_match(self):
# Arrange
entities = self._create_table_with_default_entities(self.table_name, 1)
# Act
sent_entity = self._create_updated_entity_dict('MyPartition','1')
with self.assertRaises(WindowsAzureError):
self.tc.update_entity(self.table_name, 'MyPartition', '1', sent_entity, if_match=u'W/"datetime\'2012-06-15T22%3A51%3A44.9662825Z\'"')
# Assert
def test_insert_or_merge_entity_with_existing_entity(self):
# Arrange
self._create_table_with_default_entities(self.table_name, 1)
# Act
sent_entity = self._create_updated_entity_dict('MyPartition','1')
resp = self.tc.insert_or_merge_entity(self.table_name, 'MyPartition', '1', sent_entity)
# Assert
self.assertIsNotNone(resp)
received_entity = self.tc.get_entity(self.table_name, 'MyPartition', '1')
self._assert_merged_entity(received_entity)
def test_insert_or_merge_entity_with_non_existing_entity(self):
# Arrange
self._create_table(self.table_name)
# Act
sent_entity = self._create_updated_entity_dict('MyPartition','1')
resp = self.tc.insert_or_merge_entity(self.table_name, 'MyPartition', '1', sent_entity)
# Assert
self.assertIsNotNone(resp)
received_entity = self.tc.get_entity(self.table_name, 'MyPartition', '1')
self._assert_updated_entity(received_entity)
def test_insert_or_replace_entity_with_existing_entity(self):
# Arrange
self._create_table_with_default_entities(self.table_name, 1)
# Act
sent_entity = self._create_updated_entity_dict('MyPartition','1')
resp = self.tc.insert_or_replace_entity(self.table_name, 'MyPartition', '1', sent_entity)