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


Python ObjFactory.object_iter方法代码示例

本文整理汇总了Python中misc_utils_objectfactory.ObjFactory.object_iter方法的典型用法代码示例。如果您正苦于以下问题:Python ObjFactory.object_iter方法的具体用法?Python ObjFactory.object_iter怎么用?Python ObjFactory.object_iter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在misc_utils_objectfactory.ObjFactory的用法示例。


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

示例1: Test_SchoolSched_create_secondary_objects_type

# 需要导入模块: from misc_utils_objectfactory import ObjFactory [as 别名]
# 或者: from misc_utils_objectfactory.ObjFactory import object_iter [as 别名]
class Test_SchoolSched_create_secondary_objects_type(unittest.TestCase):
    
    # test that when a lesson object is created, all other records
    # that are new are created by asserting that the values are of
    # the correct object type

    def setUp(self):
        self.database = Database('htmlparser',True)
        self.of = ObjFactory(True)
    
    def test_(self):
        
        _dm = _cdict(['schedule_num','day_num','period_num','student_num'],[1,0,1,0])
    
        datamembers = _initdatamembers('lesson',**_dm)
    
        _enrich('QUAD CAFE',datamembers)
        
        _lesson_create(datamembers,self.database,self.of)

        attr_list = [(obj, obj.objtype) for obj in self.of.object_iter()]

        for obj in self.of.object_iter():
            self.assertTrue(isinstance(obj,eval(obj.objtype)))
            
        with self.database:
            pass
开发者ID:burtnolej,项目名称:hungrycrayon,代码行数:29,代码来源:test_schoolscheduler.py

示例2: Test_ObjFrameworkIter

# 需要导入模块: from misc_utils_objectfactory import ObjFactory [as 别名]
# 或者: from misc_utils_objectfactory.ObjFactory import object_iter [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

示例3: Test_SchoolSched_create_secondary_objects_with_teacher

# 需要导入模块: from misc_utils_objectfactory import ObjFactory [as 别名]
# 或者: from misc_utils_objectfactory.ObjFactory import object_iter [as 别名]
class Test_SchoolSched_create_secondary_objects_with_teacher(unittest.TestCase):
    
    # test that when a lesson object is created, all other records
    # that are new are created by asserting the contents of the
    # objfactory store

    def setUp(self):
        self.database = Database('htmlparser')
        self.of = ObjFactory(True)
    
    def test_(self):
        
        _dm = _cdict(['schedule_num','day_num','period_num','student_num'],[1,0,1,0])
    
        datamembers = _initdatamembers('lesson',**_dm)
    
        _enrich('Science WP With: Kayla',datamembers)

        #exp_res = [('None','teacher'),
                   
        exp_res =  [('KAYLA','teacher'),
                    ('9:11-9:51','period'),
                   ('NATHANIEL','student'),
                   ('Monday','dow'),
                   ('1.0.1','lesson'),
                   ('wp','lessontype'),
                   ('SCIENCE','subject')]


        _lesson_create(datamembers,self.database,self.of)

        attr_list = [(obj.userdefid, obj.objtype) for obj in self.of.object_iter() if obj.objtype not in ['objtype','userdefid']]

        attr_list.sort()
        exp_res.sort()
        
        #_pprint(exp_res,attr_list)
        self.assertListEqual(attr_list,exp_res)
开发者ID:burtnolej,项目名称:hungrycrayon,代码行数:40,代码来源:test_schoolscheduler.py

示例4: Test_SchoolSched_persist_multi

# 需要导入模块: from misc_utils_objectfactory import ObjFactory [as 别名]
# 或者: from misc_utils_objectfactory.ObjFactory import object_iter [as 别名]
class Test_SchoolSched_persist_multi(unittest.TestCase):

    # test that a lesson object is persisted to the db correctly
    # by asserting the fields written into the database table
    def setUp(self):
        self.database = Database('htmlparser')
        self.of = ObjFactory(True)
        
        self._create('Math WP With: Moira', [1,2,7,0])
        self._create('HUMANITIES',[1,4,9,0])
        self._create('Math WP With: Moira',[1,2,3,0])
        self._persist()

    def _create(self,lessonname,params):
        
        _dm = _cdict(['schedule_num','day_num','period_num','student_num'],params)
        datamembers = _initdatamembers('lesson',**_dm)
        _enrich(lessonname,datamembers)
        
        _lesson_create(datamembers,self.database,self.of)

    def _persist(self):
        
        with self.database:
            for obj in self.of.object_iter():
                obj.persist()
            
    def test_persist_multi_lesson(self):
        self.database = Database('htmlparser',True)
        with self.database:
            self.assertEquals(tbl_count_get(self.database,'lesson'),3)
            
    def test_persist_multi_teacher(self):
        self.database = Database('htmlparser',True)
        with self.database:
            self.assertEquals(tbl_count_get(self.database,'teacher'),1)
            _,rowvals = tbl_rows_get(self.database,'teacher',['userdefid'])
                 
        self.assertListEqual(rowvals,[['MOIRA']])
            
    def test_persist_multi_subject(self):
        self.database = Database('htmlparser',True)
        with self.database:
            self.assertEquals(tbl_count_get(self.database,'subject'),2)
            _,rowvals = tbl_rows_get(self.database,'subject',['userdefid'])
        
        rowvals.sort()         
        self.assertListEqual(rowvals,[['HUMANITIES'],['MATH']])
            
    def test_persist_multi_dow(self):
        self.database = Database('htmlparser',True)
        with self.database:
            self.assertEquals(tbl_count_get(self.database,'dow'),2)
            _,rowvals = tbl_rows_get(self.database,'dow',['userdefid'])
        
        rowvals.sort()   
        self.assertListEqual(rowvals,[['Friday'],['Wednesday']])
        
    def test_persist_multi_period(self):
        self.database = Database('htmlparser',True)
        with self.database:
            self.assertEquals(tbl_count_get(self.database,'period'),3)
            _,rowvals = tbl_rows_get(self.database,'period',['userdefid'])
        
        rowvals.sort()
        self.assertListEqual(rowvals,[['10:33-11:13'],['1:07-1:47'],['2:30-3:00']])
            
    def test_persist_multi_student(self):
        self.database = Database('htmlparser',True)
        with self.database:
            self.assertEquals(tbl_count_get(self.database,'student'),1)
            _,rowvals = tbl_rows_get(self.database,'student',['userdefid'])
                 
        self.assertListEqual(rowvals,[['NATHANIEL']])
开发者ID:burtnolej,项目名称:hungrycrayon,代码行数:76,代码来源:test_schoolscheduler.py


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