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