當前位置: 首頁>>代碼示例>>Python>>正文


Python ObjFactory.reset方法代碼示例

本文整理匯總了Python中misc_utils_objectfactory.ObjFactory.reset方法的典型用法代碼示例。如果您正苦於以下問題:Python ObjFactory.reset方法的具體用法?Python ObjFactory.reset怎麽用?Python ObjFactory.reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在misc_utils_objectfactory.ObjFactory的用法示例。


在下文中一共展示了ObjFactory.reset方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Test_ObjFramework_2_records_same_cls

# 需要導入模塊: from misc_utils_objectfactory import ObjFactory [as 別名]
# 或者: from misc_utils_objectfactory.ObjFactory import reset [as 別名]
class Test_ObjFramework_2_records_same_cls(unittest.TestCase):

    def setUp(self):
        self.of = ObjFactory()
        self.obj1= self.of.new(GenericBase,
                               'Student',
                               objid='booker',
                               modname=__name__,
                               name='booker',
                               age=23)
        
        self.obj2= self.of.new(GenericBase,
                               'Student',
                               objid='frank',
                               modname=__name__,
                               name='frank',
                               age=19)
        

    def tearDown(self):
        self.of.reset()
        
    def test_2records_same_class(self):
        names = [obj.name for obj in self.of.query('Student')]
        names.sort()
        self.assertEquals(names,['booker','frank'])
開發者ID:burtnolej,項目名稱:hungrycrayon,代碼行數:28,代碼來源:test_misc_utils_objectfactory.py

示例2: Test_ObjFramework_Database

# 需要導入模塊: from misc_utils_objectfactory import ObjFactory [as 別名]
# 或者: from misc_utils_objectfactory.ObjFactory import reset [as 別名]
class Test_ObjFramework_Database(unittest.TestCase):


    def setUp(self):
        self.of = ObjFactory(True)
        self.database = Database('foobar')
        self.foobar= self.of.new(dbtblgeneric,
                                 'DBLesson',
                                 objid='dblesson0',
                                 constructor='datamembers',
                                 modname=__name__,
                                 database=self.database,
                                 dm={'student':'booker',
                                     'period':2,
                                     'dow':3})
        
    def tearDown(self):
        self.of.reset()

    def test_num_obj_created(self):
        self.assertEquals(len(self.of.query('DBLesson')),1)
        
    def test_correct_keys_created(self):
        self.assertTrue(self.of.object_exists('DBLesson','dblesson0'))

    
    def test_objects_created_stored(self):
        _lesson = self.of.object_get('DBLesson','dblesson0')
        self.assertEquals(_lesson.__class__.__name__,"DBLesson")

    def test_objects_have_attributes(self):
        _lesson = self.of.object_get('DBLesson','dblesson0')  
        self.assertEquals(_lesson.student,'booker')
        self.assertEquals(_lesson.period,2)
        self.assertEquals(_lesson.dow,3)
開發者ID:burtnolej,項目名稱:hungrycrayon,代碼行數:37,代碼來源:test_misc_utils_objectfactory.py

示例3: Test_ObjFrameworkIter

# 需要導入模塊: from misc_utils_objectfactory import ObjFactory [as 別名]
# 或者: from misc_utils_objectfactory.ObjFactory import reset [as 別名]
class Test_ObjFrameworkIter(unittest.TestCase):

    def setUp(self):
        self.of = ObjFactory(True)
        self.of.new(GenericBase,
                    'Student',
                    objid='booker',
                    modname=__name__)
        
        self.of.new(GenericBase,
                    'Student',
                    objid='fred',
                    modname=__name__)
        
        self.of.new(GenericBase,
                    'Classroom',
                    objid='1a',
                    modname=__name__)
        

    def tearDown(self):
        self.of.reset()
        
    def test_iter(self):
        result = [obj.objid for obj in self.of.object_iter()]
        result.sort()
        
        self.assertListEqual(result,['1a','booker','fred'])
開發者ID:burtnolej,項目名稱:hungrycrayon,代碼行數:30,代碼來源:test_misc_utils_objectfactory.py

示例4: Test_ObjFrameworkBasic

# 需要導入模塊: from misc_utils_objectfactory import ObjFactory [as 別名]
# 或者: from misc_utils_objectfactory.ObjFactory import reset [as 別名]
class Test_ObjFrameworkBasic(unittest.TestCase):

    def setUp(self):
        self.of = ObjFactory()

        foobar= self.of.new(GenericBase,
                            "Student",
                            objid='booker',
                            modname=__name__,
                            name='booker',
                            age=23)      

    def tearDown(self):
        self.of.reset()
        
    def test_num_obj_created(self):
        self.assertEquals(len(ObjFactory().store['Student']),1)
        
    def test_correct_keys_created(self):
        self.assertTrue(ObjFactory().store['Student'].has_key('booker'))
    
    def test_objects_created_stored(self):
        _student = ObjFactory().store['Student']['booker']
        self.assertEquals(_student.__class__.__name__,"Student")

    def test_objects_have_attributes(self):
        _student = ObjFactory().store['Student']['booker']        
        self.assertEquals(_student.name,'booker')
        self.assertEquals(_student.age,23)
開發者ID:burtnolej,項目名稱:hungrycrayon,代碼行數:31,代碼來源:test_misc_utils_objectfactory.py

示例5: Test_ObjFrameworkDumpNested

# 需要導入模塊: from misc_utils_objectfactory import ObjFactory [as 別名]
# 或者: from misc_utils_objectfactory.ObjFactory import reset [as 別名]
class Test_ObjFrameworkDumpNested(unittest.TestCase):

    def setUp(self):
        self.of = ObjFactory(True)
        self.obj1 = self.of.new(GenericBase,
                    'Student',
                    objid='booker',
                    nationality='british',
                    modname=__name__)
        
        self.of.new(GenericBase,
                    'Student',
                    objid='fred',
                    age=23,
                    nationality='british',
                    modname=__name__)
        
        self.of.new(GenericBase,
                    'Student',
                    objid='fred',
                    age=35,
                    nationality='irish',
                    modname=__name__)
        
        self.of.new(GenericBase,
                    'Classroom',
                    objid='1a',
                    nationality='swedish',
                    modname=__name__)
        

    def tearDown(self):
        self.of.reset()
        
    '''def test_1clause(self):
        results = self.of.query_advanced('Student',[('objid','booker')])
        
        self.assertEquals(len(results),1)
        self.assertEquals(results[0].objid,'booker')
        
    def test_2clause(self):
        results = self.of.query_advanced('Student',[('nationality','british'),
                                                    ('objid','fred')])
        
        self.assertEquals(len(results),1)
        self.assertEquals(results[0].age,23)'''
        
        
    def test_update_then_search(self):
        ''' make sure that search picks up the updated version of the object '''
        
        self.obj1.nationality = 'indian'
        results = self.of.query_advanced('Student',[('objid','booker')])
        
        self.assertEquals(results[0].nationality,'indian')
開發者ID:burtnolej,項目名稱:hungrycrayon,代碼行數:57,代碼來源:test_misc_utils_objectfactory.py

示例6: Test_ObjFrameworkDupeID

# 需要導入模塊: from misc_utils_objectfactory import ObjFactory [as 別名]
# 或者: from misc_utils_objectfactory.ObjFactory import reset [as 別名]
class Test_ObjFrameworkDupeID(unittest.TestCase):

    def setUp(self):
        self.of = ObjFactory()
        self.obj1= self.of.new(GenericBase,
                               'Student',
                               objid='booker',
                               modname=__name__)
        
        self.obj2= self.of.new(GenericBase,
                               'Student',
                               objid='booker',
                               modname=__name__)
        

    def tearDown(self):
        self.of.reset()
        
    def test_num_dupe_objid(self):
        self.assertEqual(self.obj1,self.obj2)
開發者ID:burtnolej,項目名稱:hungrycrayon,代碼行數:22,代碼來源:test_misc_utils_objectfactory.py

示例7: Test_ObjFramework_2_class

# 需要導入模塊: from misc_utils_objectfactory import ObjFactory [as 別名]
# 或者: from misc_utils_objectfactory.ObjFactory import reset [as 別名]
class Test_ObjFramework_2_class(unittest.TestCase):

    def setUp(self):
        self.of = ObjFactory()
        self.obj1= self.of.new(GenericBase,
                               'Student',
                               objid='booker',
                               modname=__name__,
                               name='booker',
                               age=23)
        
        self.obj2= self.of.new(GenericBase,
                               'Subject',
                               objid='science',
                               modname=__name__,
                               name='science',
                               teacher_name='fran')
        

    def tearDown(self):
        self.of.reset()
        
    def test_2_class(self):
        self.assertListEqual(self.of.query(),['Student','Subject'])
開發者ID:burtnolej,項目名稱:hungrycrayon,代碼行數:26,代碼來源:test_misc_utils_objectfactory.py

示例8: SSViewer

# 需要導入模塊: from misc_utils_objectfactory import ObjFactory [as 別名]
# 或者: from misc_utils_objectfactory.ObjFactory import reset [as 別名]

#.........這裏部分代碼省略.........
            # indexed by dow/period
            if obj.lessons.has_key(xtype_id) == False:
                obj.lessons[xtype_id] = {} 
    
            if obj.lessons[xtype_id].has_key(ytype_id) == False:
                obj.lessons[xtype_id][ytype_id] = []
                
            obj.lessons[xtype_id][ytype_id].append(lesson)
        
        adult = lesson.adult
        student = lesson.student

        # add the lesson to the adult object        
        if hasattr(adult,'lessons') == False:
            setattr(adult,'lessons',{})
            
        _add(adult,'dow','period',lesson) # indexed by dow/period
        _add(adult,'student','period',lesson) # indexed by student/period

        # add the lesson to the student object
        if hasattr(student,'lessons') == False:
            setattr(student,'lessons',{})
            
        _add(student,'dow','period',lesson) # indexed by dow/period
        _add(student,'adult','period',lesson) # indexed by adult/period
        _add(student,'period','recordtype',lesson) # indexed by adult/period
        _add(student,'student','recordtype',lesson) # indexed by adult/period
        

    @logger(log)       
    def load(self,saveversion, dow=None, prep=None, period=None, teacher=None, student=None, source=None,
             unknown='N'):
        
        self.of.reset()
            
        whereclause = []
        
        # unknown
        if unknown=='N':
            whereclause.append(['student',"<>","\"??\""])
            whereclause.append(['subject',"<>","\"??\""])
            whereclause.append(['teacher',"<>","\"??\""])
        log.log(thisfuncname(),3,msg="loading",unknown=str(unknown))
            
        # prep
        if prep==None:
            prep = -1
        else:
            whereclause.append(['prep',"=",prep])
        log.log(thisfuncname(),3,msg="loading",prep=str(prep))
        
        # period
        if period==None: 
            prep = -1
        else:
            whereclause.append(['period',"=","\""+period+"\""])            
        log.log(thisfuncname(),3,msg="loading",prep=str(prep))

        # dow
        if dow==None:
            dow = "all"
        else:
            whereclause.append( ['dow',"=","\""+dow+"\""])
        log.log(thisfuncname(),3,msg="loading",dow=str(dow))
        
        
開發者ID:burtnolej,項目名稱:hungrycrayon,代碼行數:68,代碼來源:ssviewer_headless.py

示例9: Test_ObjFrameworkDumpRptNestedSchoolsched

# 需要導入模塊: from misc_utils_objectfactory import ObjFactory [as 別名]
# 或者: from misc_utils_objectfactory.ObjFactory import reset [as 別名]

#.........這裏部分代碼省略.........
        
        
    def test_(self):
        from types import StringType,IntType, UnicodeType
        results = self.of.dumpobjrpt(objref=False)
        
        expected_results = [['ROOT', 'period'], 
                            ['ROOT', 'saveversion'], 
                            ['ROOT', 'dow'], 
                            ['dblesson0', 'dow'], 
                            ['dblesson0', 'period'], 
                            ['dblesson0', 'saveversion'], 
                            ['dblesson0', 'session'], 
                            ['dblesson0', 'student'], 
                            ['dblesson0', 'teacher'], 
                            ['ROOT', 'DBLesson'], 
                            ['ROOT', 'session'], 
                            ['ROOT', 'student'], 
                            ['ROOT', 'teacher']]
        
        self.assertListEqual(expected_results,results)

    def test_filter_objtype(self):
        from types import StringType,IntType, UnicodeType
        results = self.of.dumpobjrpt(objtypes=['DBLesson','student'],objref=False)
         
        expected_results = [['dblesson0', 'student'], 
                            ['ROOT', 'DBLesson'],
                            ['ROOT', 'student']]
        
        
        expected_results.sort()
        results.sort()
        
        self.assertListEqual(expected_results,results)
        
    def test_filter_objtype_3items(self):
        from types import StringType,IntType, UnicodeType
        results = self.of.dumpobjrpt(objtypes=['DBLesson','student','dow'],objref=False)
         
        expected_results = [['dblesson0', 'student'], 
                            ['ROOT', 'DBLesson'],
                            ['ROOT', 'student'],
                            ['dblesson0', 'dow'], 
                            ['ROOT', 'dow']] 
        
        
        expected_results.sort()
        results.sort()
        
        self.assertListEqual(expected_results,results)
        
    
    def test_filter_objtype_field_filters(self):
        from types import StringType,IntType, UnicodeType
        
        expected_results = [['ROOT', '-', '-', 'student'], 
                            ['ROOT', 'Amelia', 'Booker', 'DBLesson'], 
                            ['dblesson0', '-', '-', 'student']]


        results = self.of.dumpobjrpt(objtypes=['DBLesson','student'],
                                     objref=False,
                                     fields=['teacher','student'])
         
        
        expected_results.sort()
        results.sort()
        
        self.assertListEqual(expected_results,results)
        

    def test_all_fields(self):
        from types import StringType,IntType, UnicodeType
        
        expected_results = [['ROOT', 'dm:teacher=Amelia', 
                             'dm:session=AM.AC.SC', 'dm:student=Booker', 
                             'dm:period=830', 'dm:saveversion=0', 
                             'dm:dow=MO', 'dm:dm:dow=MO', 'dow:MO', 
                             'objid:dblesson0', 'period:830', 
                             'recursion:True', 'saveversion:0', 
                             'session:AM.AC.SC', 'student:Booker', 
                             'teacher:Amelia']]

        results = self.of.dumpobjrpt(objtypes=['DBLesson'],
                                     objref=False,
                                     fields=['all'],
                                     omitfields=['id'],
                                     fieldnames=True)
         
        
        expected_results.sort()
        results.sort()

        self.assertListEqual(expected_results,results)
        

        
    def tearDown(self):
        self.of.reset()
開發者ID:burtnolej,項目名稱:hungrycrayon,代碼行數:104,代碼來源:test_misc_utils_objectfactory.py


注:本文中的misc_utils_objectfactory.ObjFactory.reset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。