本文整理汇总了Python中girder.models.model_base.Model._overwriteFields方法的典型用法代码示例。如果您正苦于以下问题:Python Model._overwriteFields方法的具体用法?Python Model._overwriteFields怎么用?Python Model._overwriteFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类girder.models.model_base.Model
的用法示例。
在下文中一共展示了Model._overwriteFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testProjectionUtils
# 需要导入模块: from girder.models.model_base import Model [as 别名]
# 或者: from girder.models.model_base.Model import _overwriteFields [as 别名]
def testProjectionUtils(self):
def assertItemsEqual(a, b):
self.assertEqual(len(a), len(b))
self.assertEqual(sorted(a), sorted(b))
inclusionProjDict = {
'public': True,
'access': True,
'email': True,
'login': True
}
inclusionProjList = ['public', 'access', 'email', 'login']
exclusionProjDict = {
'public': False,
'access': False,
'email': False,
'login': False
}
overrideFields = {'access', 'public'}
copy = dict(inclusionProjDict)
retval = Model._overwriteFields(inclusionProjDict, overrideFields)
assertItemsEqual(retval, inclusionProjDict)
assertItemsEqual(inclusionProjDict, copy)
retval = Model._overwriteFields(inclusionProjList, overrideFields)
assertItemsEqual(retval, inclusionProjList)
retval = Model._overwriteFields(exclusionProjDict, {'newValue'})
assertItemsEqual(retval, exclusionProjDict)
retval = Model._overwriteFields(inclusionProjDict, {'newValue'})
assertItemsEqual(retval, {
'public': True,
'access': True,
'email': True,
'login': True,
'newValue': True
})
retval = Model._overwriteFields(exclusionProjDict, overrideFields)
assertItemsEqual(retval, {'email': False, 'login': False})
doc = {
'public': True,
'access': True,
'email': '[email protected]',
'login': 'login',
'password': 'password1',
'admin': False,
'firstName': 'first',
'lastName': 'last'
}
Model._removeOverwrittenFields(doc, exclusionProjDict)
assertItemsEqual(doc, {
'password': 'password1',
'admin': False,
'firstName': 'first',
'lastName': 'last'})
doc = {
'public': True,
'access': True,
'email': '[email protected]',
'login': 'login',
'password': 'password1',
'admin': False,
'firstName': 'first',
'lastName': 'last'
}
Model._removeOverwrittenFields(doc, inclusionProjList)
assertItemsEqual(doc, {
'public': True,
'access': True,
'email': '[email protected]',
'login': 'login'})
doc = {
'public': True,
'access': True,
'email': '[email protected]',
'login': 'login',
'password': 'password1',
'admin': False,
'firstName': 'first',
'lastName': 'last'
}
Model._removeOverwrittenFields(doc, inclusionProjDict)
assertItemsEqual(doc, {
'public': True,
'access': True,
'email': '[email protected]',
'login': 'login'})
# Test None edge cases
retval = Model._overwriteFields(None, {'access', 'public'})
self.assertIsNone(retval)
copy = dict(doc)
Model._removeOverwrittenFields(doc, None)
assertItemsEqual(copy, doc)
# Test '_id': False inclusion edge case
fields = {
'_id': False,
#.........这里部分代码省略.........