当前位置: 首页>>代码示例>>Python>>正文


Python model_base.Model类代码示例

本文整理汇总了Python中girder.models.model_base.Model的典型用法代码示例。如果您正苦于以下问题:Python Model类的具体用法?Python Model怎么用?Python Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Model类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testInclusionProjDict

 def testInclusionProjDict(self, doc, inclusionProjDict):
     Model._removeSupplementalFields(doc, inclusionProjDict)
     assert doc == {
         '_id': '1234',
         'public': True,
         'access': True,
         'email': '[email protected]',
         'login': 'login'}
开发者ID:girder,项目名称:girder,代码行数:8,代码来源:test_model.py

示例2: testExclusionProjDict

 def testExclusionProjDict(self, doc, exclusionProjDict):
     Model._removeSupplementalFields(doc, exclusionProjDict)
     assert doc == {
         '_id': '1234',
         'password': 'password1',
         'admin': False,
         'firstName': 'first',
         'lastName': 'last'}
开发者ID:girder,项目名称:girder,代码行数:8,代码来源:test_model.py

示例3: validate

    def validate(self, doc):
        if doc.get('score') is not None and doc.get('overallScore') is None:
            scoring.computeAverageScores(doc['score'])
            phase = self.model('phase', 'challenge').load(
                doc['phaseId'], force=True)
            doc['overallScore'] = scoring.computeOverallScore(doc, phase)
            doc['latest'] = True

            Model.update(self, query={
                'phaseId': doc['phaseId'],
                'creatorId': doc['creatorId'],
                'latest': True
            }, update={
                '$set': {'latest': False}
            })

        return doc
开发者ID:jeffbaumes,项目名称:covalic,代码行数:17,代码来源:submission.py

示例4: testInclusionProjDictNewValue

 def testInclusionProjDictNewValue(self, inclusionProjDict):
     retval = Model._supplementFields(inclusionProjDict, {'newValue'})
     assert retval == {
         'public': True,
         'access': True,
         'email': True,
         'login': True,
         'newValue': True
     }
开发者ID:girder,项目名称:girder,代码行数:9,代码来源:test_model.py

示例5: testFlaseInclusionEdgeCase

 def testFlaseInclusionEdgeCase(self):
     doc = {
         '_id': 'id',
         'login': 'login',
         'email': '[email protected]',
         'firstName': 'fname',
         'lastName': 'lname'
     }
     fields = {
         '_id': False,
         'login': True,
         'email': True,
         'firstName': True,
         'lastName': True
     }
     Model._removeSupplementalFields(doc, fields)
     assert doc == {
         'login': 'login',
         'email': '[email protected]',
         'firstName': 'fname',
         'lastName': 'lname'}
开发者ID:girder,项目名称:girder,代码行数:21,代码来源:test_model.py

示例6: validate

    def validate(self, doc):
        if doc.get('created'):
            doc['created'] = validateDate(doc.get('created'), 'created')

        if doc.get('approach') in {'default', ''}:
            del doc['approach']

        if doc.get('score') is not None and doc.get('overallScore') is None:
            scoring.computeAverageScores(doc['score'])
            phase = Phase().load(
                doc['phaseId'], force=True)
            doc['overallScore'] = scoring.computeOverallScore(doc, phase)
            doc['latest'] = True

            Model.update(self, query={
                'phaseId': doc['phaseId'],
                'creatorId': doc['creatorId'],
                'approach': doc.get('approach'),
                'latest': True
            }, update={
                '$set': {'latest': False}
            })

        return doc
开发者ID:girder,项目名称:covalic,代码行数:24,代码来源:submission.py

示例7: testFalseInclusionEdgeCase

 def testFalseInclusionEdgeCase(self):
     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._supplementFields(fields, overwrite)
     assert retval == overwrittenFields
开发者ID:girder,项目名称:girder,代码行数:18,代码来源:test_model.py

示例8: testNoneEdgeCase

 def testNoneEdgeCase(self):
     # Test None edge cases
     retval = Model._supplementFields(None, {'access', 'public'})
     assert retval is None
开发者ID:girder,项目名称:girder,代码行数:4,代码来源:test_model.py

示例9: testExclusionProjDictOverride

 def testExclusionProjDictOverride(self, exclusionProjDict, overrideFields):
     retval = Model._supplementFields(exclusionProjDict, overrideFields)
     assert retval == {'email': False, 'login': False}
开发者ID:girder,项目名称:girder,代码行数:3,代码来源:test_model.py

示例10: testExclusionProjDictNewValue

 def testExclusionProjDictNewValue(self, exclusionProjDict):
     retval = Model._supplementFields(exclusionProjDict, {'newValue'})
     assert retval == exclusionProjDict
开发者ID:girder,项目名称:girder,代码行数:3,代码来源:test_model.py

示例11: testInclusionProjListOverride

 def testInclusionProjListOverride(self, inclusionProjList, overrideFields):
     retval = Model._supplementFields(inclusionProjList, overrideFields)
     assert set(retval) == set(inclusionProjList)
开发者ID:girder,项目名称:girder,代码行数:3,代码来源:test_model.py

示例12: testInclusionProjectDictOverride

 def testInclusionProjectDictOverride(self, inclusionProjDict, overrideFields):
     copy = dict(inclusionProjDict)
     retval = Model._supplementFields(inclusionProjDict, overrideFields)
     assert retval == inclusionProjDict
     assert inclusionProjDict == copy
开发者ID:girder,项目名称:girder,代码行数:5,代码来源:test_model.py

示例13: testProjectionUtils

    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,
#.........这里部分代码省略.........
开发者ID:adsorensen,项目名称:girder,代码行数:101,代码来源:model_test.py

示例14: remove

    def remove(self, doc, progress=noProgress):
        folder = self.model('folder').load(doc['folderId'], force=True)
        if folder:
            self.model('folder').remove(folder)

        Model.remove(self, doc, progress=progress)
开发者ID:jeffbaumes,项目名称:covalic,代码行数:6,代码来源:submission.py

示例15: testEmptyDict

 def testEmptyDict(self):
     assert Model._isInclusionProjection({}) is True
开发者ID:girder,项目名称:girder,代码行数:2,代码来源:test_model.py


注:本文中的girder.models.model_base.Model类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。