當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。