本文整理汇总了Python中b2handle.handleclient.EUDATHandleClient.get_handlerecord_indices_for_key方法的典型用法代码示例。如果您正苦于以下问题:Python EUDATHandleClient.get_handlerecord_indices_for_key方法的具体用法?Python EUDATHandleClient.get_handlerecord_indices_for_key怎么用?Python EUDATHandleClient.get_handlerecord_indices_for_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类b2handle.handleclient.EUDATHandleClient
的用法示例。
在下文中一共展示了EUDATHandleClient.get_handlerecord_indices_for_key方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EUDATHandleClientReadaccessFakedTestCase
# 需要导入模块: from b2handle.handleclient import EUDATHandleClient [as 别名]
# 或者: from b2handle.handleclient.EUDATHandleClient import get_handlerecord_indices_for_key [as 别名]
#.........这里部分代码省略.........
dict_record = self.inst.retrieve_handle_record(handle, handlerecord)
self.assertIn('test1', dict_record,
'Key "test1" not in handlerecord dictionary!')
self.assertIn('test2', dict_record,
'Key "test2" not in handlerecord dictionary!')
self.assertIn('testdup', dict_record,
'Key "testdup" not in handlerecord dictionary!')
self.assertIn('HS_ADMIN', dict_record,
'Key "HS_ADMIN" not in handlerecord dictionary!')
self.assertEqual(dict_record['test1'], 'val1',
'The value of "test1" is not "val1.')
self.assertEqual(dict_record['test2'], 'val2',
'The value of "test2" is not "val2.')
self.assertIn(dict_record['testdup'], ("dup1", "dup2"),
'The value of the duplicate key "testdup" should be "dup1" or "dup2".')
self.assertIn('permissions', dict_record['HS_ADMIN'],
'The HS_ADMIN has no permissions: '+dict_record['HS_ADMIN'])
self.assertEqual(len(dict_record), 4,
'The record should have a length of 5 (as the duplicate is ignored.')
# get_handlerecord_indices_for_key
def test_get_indices_for_key_normal(self):
"""Test getting the indices for a specific key."""
handlerecord = json.load(open('resources/handlerecord_for_reading.json'))
handle = handlerecord['handle']
indices = self.inst.get_handlerecord_indices_for_key('test1', handlerecord['values'])
self.assertEqual(len(indices),1,
'There is more or less than 1 index!')
self.assertEqual(indices[0], 3,
'The index of "test1" is not 3.')
def test_get_indices_for_key_duplicatekey(self):
"""Test getting the indices for a duplicate key."""
handlerecord = json.load(open('resources/handlerecord_for_reading.json'))
handle = handlerecord['handle']
indices = self.inst.get_handlerecord_indices_for_key('testdup', handlerecord['values'])
self.assertEqual(len(indices),2,
'There is more or less than 2 indices!')
self.assertIn(5, indices,
'5 is not in indices for key "testdup".')
self.assertIn(6, indices,
'6 is not in indices for key "testdup".')
def test_get_indices_for_key_inexistentkey(self):
"""Test getting the indices for an inexistent key."""
handlerecord = json.load(open('resources/handlerecord_for_reading.json'))
handle = handlerecord['handle']
indices = self.inst.get_handlerecord_indices_for_key('test100', handlerecord['values'])
self.assertEqual(len(indices),0,
'There is more than 0 index!')
self.assertEqual(indices,[],
'Indices should be an empty list!')
# is_10320LOC_empty