本文整理汇总了Python中girder.models.model_base.Model._isInclusionProjection方法的典型用法代码示例。如果您正苦于以下问题:Python Model._isInclusionProjection方法的具体用法?Python Model._isInclusionProjection怎么用?Python Model._isInclusionProjection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类girder.models.model_base.Model
的用法示例。
在下文中一共展示了Model._isInclusionProjection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testIdTrue
# 需要导入模块: from girder.models.model_base import Model [as 别名]
# 或者: from girder.models.model_base.Model import _isInclusionProjection [as 别名]
def testIdTrue(self):
assert Model._isInclusionProjection({'_id': True}) is True
示例2: testIdFalse
# 需要导入模块: from girder.models.model_base import Model [as 别名]
# 或者: from girder.models.model_base.Model import _isInclusionProjection [as 别名]
def testIdFalse(self):
assert Model._isInclusionProjection({'_id': False}) is False
示例3: testNone
# 需要导入模块: from girder.models.model_base import Model [as 别名]
# 或者: from girder.models.model_base.Model import _isInclusionProjection [as 别名]
def testNone(self):
assert Model._isInclusionProjection(None) is False
示例4: testEmptyDict
# 需要导入模块: from girder.models.model_base import Model [as 别名]
# 或者: from girder.models.model_base.Model import _isInclusionProjection [as 别名]
def testEmptyDict(self):
assert Model._isInclusionProjection({}) is True
示例5: testProjectionUtils
# 需要导入模块: from girder.models.model_base import Model [as 别名]
# 或者: from girder.models.model_base.Model import _isInclusionProjection [as 别名]
#.........这里部分代码省略.........
'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,
'login': True,
'email': True,
'firstName': True,
'lastName': True
}
overwrittenFields = {
'_id': True,
'login': True,
'email': True,
'firstName': True,
'lastName': True
}
overwrite = {'_id', 'login'}
retval = Model._overwriteFields(fields, overwrite)
assertItemsEqual(retval, overwrittenFields)
doc = {
'_id': 'id',
'login': 'login',
'email': '[email protected]',
'firstName': 'fname',
'lastName': 'lname'
}
Model._removeOverwrittenFields(doc, fields)
assertItemsEqual(doc, {
'login': 'login',
'email': '[email protected]',
'firstName': 'fname',
'lastName': 'lname'})
# Test _isInclusionProjection edge cases
self.assertEqual(Model._isInclusionProjection(None), False)
self.assertEqual(Model._isInclusionProjection({}), True)
self.assertEqual(Model._isInclusionProjection({'_id': False}), False)
self.assertEqual(Model._isInclusionProjection({'_id': True}), True)