当前位置: 首页>>代码示例>>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;未经允许,请勿转载。