本文整理匯總了Python中azure.storage.TableService.set_table_service_properties方法的典型用法代碼示例。如果您正苦於以下問題:Python TableService.set_table_service_properties方法的具體用法?Python TableService.set_table_service_properties怎麽用?Python TableService.set_table_service_properties使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類azure.storage.TableService
的用法示例。
在下文中一共展示了TableService.set_table_service_properties方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TableServiceTest
# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import set_table_service_properties [as 別名]
#.........這裏部分代碼省略.........
self.assertEqual(entity.sign, 'aquarius')
self.assertFalse(hasattr(entity, "optional"))
self.assertFalse(hasattr(entity, "ratio"))
self.assertFalse(hasattr(entity, "large"))
self.assertFalse(hasattr(entity, "Birthday"))
self.assertEqual(entity.birthday, datetime(1991, 10, 4, tzinfo=tzutc()))
self.assertFalse(hasattr(entity, "other"))
self.assertFalse(hasattr(entity, "clsid"))
self.assertTrue(hasattr(entity, "Timestamp"))
def _assert_merged_entity(self, entity):
'''
Asserts that the entity passed in matches the default entity
merged with the updated entity.
'''
self.assertEqual(entity.age, 'abc')
self.assertEqual(entity.sex, 'female')
self.assertEqual(entity.sign, 'aquarius')
self.assertEqual(entity.married, True)
self.assertEqual(entity.deceased, False)
self.assertEqual(entity.sign, 'aquarius')
self.assertEqual(entity.ratio, 3.1)
self.assertEqual(entity.large, 9333111000)
self.assertEqual(entity.Birthday, datetime(1973, 10, 4, tzinfo=tzutc()))
self.assertEqual(entity.birthday, datetime(1991, 10, 4, tzinfo=tzutc()))
self.assertEqual(entity.other, 20)
self.assertIsInstance(entity.clsid, EntityProperty)
self.assertEqual(entity.clsid.type, 'Edm.Guid')
self.assertEqual(entity.clsid.value,
'c9da6455-213d-42c9-9a79-3e9149a57833')
self.assertTrue(hasattr(entity, "Timestamp"))
#--Test cases for table service -------------------------------------------
def test_get_set_table_service_properties(self):
table_properties = self.ts.get_table_service_properties()
self.ts.set_table_service_properties(table_properties)
tests = [('logging.delete', True),
('logging.delete', False),
('logging.read', True),
('logging.read', False),
('logging.write', True),
('logging.write', False),
]
for path, value in tests:
# print path
cur = table_properties
for component in path.split('.')[:-1]:
cur = getattr(cur, component)
last_attr = path.split('.')[-1]
setattr(cur, last_attr, value)
self.ts.set_table_service_properties(table_properties)
retry_count = 0
while retry_count < MAX_RETRY:
table_properties = self.ts.get_table_service_properties()
cur = table_properties
for component in path.split('.'):
cur = getattr(cur, component)
if value == cur:
break
time.sleep(1)
retry_count += 1
self.assertEqual(value, cur)
示例2: TableServiceTest
# 需要導入模塊: from azure.storage import TableService [as 別名]
# 或者: from azure.storage.TableService import set_table_service_properties [as 別名]
#.........這裏部分代碼省略.........
self.assertEquals(entity.sex, 'female')
self.assertFalse(hasattr(entity, "married"))
self.assertFalse(hasattr(entity, "deceased"))
self.assertEquals(entity.sign, 'aquarius')
self.assertFalse(hasattr(entity, "optional"))
self.assertFalse(hasattr(entity, "ratio"))
self.assertFalse(hasattr(entity, "large"))
self.assertFalse(hasattr(entity, "Birthday"))
self.assertEquals(entity.birthday, datetime(1991,10,04))
self.assertFalse(hasattr(entity, "other"))
self.assertFalse(hasattr(entity, "clsid"))
def _assert_merged_entity(self, entity):
'''
Asserts that the entity passed in matches the default entity
merged with the updated entity.
'''
self.assertEquals(entity.age, 'abc')
self.assertEquals(entity.sex, 'female')
self.assertEquals(entity.sign, 'aquarius')
self.assertEquals(entity.married, True)
self.assertEquals(entity.deceased, False)
self.assertEquals(entity.sign, 'aquarius')
self.assertEquals(entity.ratio, 3.1)
self.assertEquals(entity.large, 9333111000)
self.assertEquals(entity.Birthday, datetime(1973,10,04))
self.assertEquals(entity.birthday, datetime(1991,10,04))
self.assertEquals(entity.other, 20)
self.assertIsInstance(entity.clsid, EntityProperty)
self.assertEquals(entity.clsid.type, 'Edm.Guid')
self.assertEquals(entity.clsid.value, 'c9da6455-213d-42c9-9a79-3e9149a57833')
#--Test cases for table service -------------------------------------------
def test_get_set_table_service_properties(self):
table_properties = self.tc.get_table_service_properties()
self.tc.set_table_service_properties(table_properties)
tests = [('logging.delete', True),
('logging.delete', False),
('logging.read', True),
('logging.read', False),
('logging.write', True),
('logging.write', False),
]
for path, value in tests:
#print path
cur = table_properties
for component in path.split('.')[:-1]:
cur = getattr(cur, component)
last_attr = path.split('.')[-1]
setattr(cur, last_attr, value)
self.tc.set_table_service_properties(table_properties)
retry_count = 0
while retry_count < MAX_RETRY:
table_properties = self.tc.get_table_service_properties()
cur = table_properties
for component in path.split('.'):
cur = getattr(cur, component)
if value == cur:
break
time.sleep(1)
retry_count += 1
self.assertEquals(value, cur)