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


Python ObjFactory.dumpobj方法代码示例

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


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

示例1: Test_ObjFrameworkDump

# 需要导入模块: from misc_utils_objectfactory import ObjFactory [as 别名]
# 或者: from misc_utils_objectfactory.ObjFactory import dumpobj [as 别名]
class Test_ObjFrameworkDump(unittest.TestCase):
    
    def setUp(self):
        self.of = ObjFactory(True)
        self.obj1 = self.of.new(GenericBase,
                    'Student',
                    objid='booker',
                    nationality='british',
                    modname=__name__)
        
    def test_(self):
        from types import StringType,IntType, UnicodeType
        expected_results = [[('pobjid', 'ROOT'),('objid', 'booker'), ('objtype', 'Student'), ('nationality', 'british')]]
                
        _results = self.of.dumpobj()
        results = []
        for result in _results:
            result.pop('id')
            results.append([(k,v) for k,v in result.iteritems() if type(v) in [IntType,StringType,UnicodeType]])
        
        expected_results.sort()
        results.sort()
        
        self.assertListEqual(expected_results,results)
开发者ID:burtnolej,项目名称:hungrycrayon,代码行数:26,代码来源:test_misc_utils_objectfactory.py

示例2: Test_ObjFrameworkDumpNestedSchoolsched

# 需要导入模块: from misc_utils_objectfactory import ObjFactory [as 别名]
# 或者: from misc_utils_objectfactory.ObjFactory import dumpobj [as 别名]
class Test_ObjFrameworkDumpNestedSchoolsched(unittest.TestCase):
    
    # same as above just with the school sched nested object
    # so each attr is another object of (not a string or int) that 
    # potentially needs to be accessed via accessors
    def setUp(self):
        self.of = ObjFactory(True)
        self.database = Database('foobar')
        
        datamembers = dict(period='830',
                           student='Booker',
                           dow='MO',
                           teacher='Amelia',
                           saveversion=0,
                           session='AM.AC.SC')

        self.foobar= self.of.new(schoolschedgeneric,
                                 'DBLesson',
                                 objid='dblesson0',
                                 constructor='datamembers',
                                 database=self.database,
                                 of=self.of,
                                 modname=__name__,
                                 dm=datamembers)
        
        
    def test_(self):
        from types import StringType,IntType, UnicodeType
            
        expected_results = [[('name', 0), ('pobjid', 'ROOT'), ('objid', 0), ('objtype', 'saveversion'), ('userobjid', 0)], 
                            [('name', 0), ('pobjid', 'dblesson0'), ('objid', 0), ('objtype', 'saveversion'), ('userobjid', 0)], 
                            [('name', '830'), ('pobjid', 'ROOT'), ('objid', '830'), ('objtype', 'period'), ('userobjid', '830')], 
                            [('name', '830'), ('pobjid', 'dblesson0'), ('objid', '830'), ('objtype', 'period'), ('userobjid', '830')], 
                            [('name', 'AM.AC.SC'), ('pobjid', 'ROOT'), ('objid', 'AM.AC.SC'), ('objtype', 'session'), ('userobjid', 'AM.AC.SC')], 
                            [('name', 'AM.AC.SC'), ('pobjid', 'dblesson0'), ('objid', 'AM.AC.SC'), ('objtype', 'session'), ('userobjid', 'AM.AC.SC')], 
                            [('name', 'Amelia'), ('pobjid', 'ROOT'), ('objid', 'Amelia'), ('objtype', 'teacher'), ('userobjid', 'Amelia')], 
                            [('name', 'Amelia'), ('pobjid', 'dblesson0'), ('objid', 'Amelia'), ('objtype', 'teacher'), ('userobjid', 'Amelia')], 
                            [('name', 'Booker'), ('pobjid', 'ROOT'), ('objid', 'Booker'), ('objtype', 'student'), ('userobjid', 'Booker')], 
                            [('name', 'Booker'), ('pobjid', 'dblesson0'), ('objid', 'Booker'), ('objtype', 'student'), ('userobjid', 'Booker')], 
                            [('name', 'MO'), ('pobjid', 'ROOT'), ('objid', 'MO'), ('objtype', 'dow'), ('userobjid', 'MO')],
                            [('name', 'MO'), ('pobjid', 'dblesson0'), ('objid', 'MO'), ('objtype', 'dow'), ('userobjid', 'MO')], 
                            [('pobjid', 'ROOT'), ('objid', 'dblesson0'), ('objtype', 'DBLesson')]]
        

        _results = self.of.dumpobj()
        results = []
        for result in _results:
            result.pop('id')
            results.append([(k,v) for k,v in result.iteritems() if type(v) in [IntType,StringType,UnicodeType]])

        expected_results.sort()
        results.sort()
        
        self.assertListEqual(expected_results,results)
        
    def test_filter_lesson(self):
        from types import StringType,IntType, UnicodeType
        
        expected_results = [[('pobjid', 'ROOT'), ('objid', 'dblesson0'), ('objtype', 'DBLesson')]]
        
        _results = self.of.dumpobj(['DBLesson'])
        results = []
        for result in _results:
            result.pop('id')
            results.append([(k,v) for k,v in result.iteritems() if type(v) in [IntType,StringType,UnicodeType]])

        expected_results.sort()
        results.sort()

        self.assertListEqual(expected_results,results)
        
    def test_filter_lesson_student(self):
        
        # will only give children of lesson or student that are of type lesson or student
        from types import StringType,IntType, UnicodeType
            
        expected_results = [[('name', 'Booker'), ('pobjid', 'ROOT'), ('objid', 'Booker'), ('objtype', 'student'), ('userobjid', 'Booker')], 
                            [('name', 'Booker'), ('pobjid', 'dblesson0'), ('objid', 'Booker'), ('objtype', 'student'), ('userobjid', 'Booker')], 
                            [('pobjid', 'ROOT'), ('objid', 'dblesson0'), ('objtype', 'DBLesson')]]


        _results = self.of.dumpobj(['DBLesson','student'])
        results = []
        for result in _results:
            result.pop('id')
            results.append([(k,v) for k,v in result.iteritems() if type(v) in [IntType,StringType,UnicodeType]])

        expected_results.sort()
        results.sort()

        self.assertListEqual(expected_results,results)
开发者ID:burtnolej,项目名称:hungrycrayon,代码行数:93,代码来源:test_misc_utils_objectfactory.py

示例3: Test_ObjFrameworkDumpNested

# 需要导入模块: from misc_utils_objectfactory import ObjFactory [as 别名]
# 或者: from misc_utils_objectfactory.ObjFactory import dumpobj [as 别名]
class Test_ObjFrameworkDumpNested(unittest.TestCase):
    
    def setUp(self):
        self.of = ObjFactory(True)


        self.student = self.of.new(GenericBase,
                                   'Student',
                                   objid='booker',
                                   nationality='british',
                                   modname=__name__)
        
        self.lesson = self.of.new(GenericBase,
                                  'Lesson',
                                  objid='1.1',
                                  period='830-910',
                                  dow='MO',
                                  student=self.student,
                                  modname=__name__)
        
    def test_(self):
        from types import StringType,IntType, UnicodeType
        expected_results = [[('pobjid', '1.1'), 
                             ('objid', 'booker'), 
                             ('objtype', 'Student'), 
                             ('nationality', 'british')], 
                            [('pobjid', 'ROOT'), 
                             ('period', '830-910'), 
                             ('dow', 'MO'), 
                             ('objid', '1.1'), 
                             ('objtype', 'Lesson')], 
                            [('pobjid', 'ROOT'), 
                             ('objid', 'booker'), 
                             ('objtype', 'Student'), 
                             ('nationality', 'british')]]

                
        _results = self.of.dumpobj()
        results = []
        for result in _results:
            result.pop('id')
            results.append([(k,v) for k,v in result.iteritems() if type(v) in [IntType,StringType,UnicodeType]])

        expected_results.sort()
        results.sort()

        self.assertListEqual(expected_results,results)
        
    def test_filter_on_lesson(self):
        
        # only report on the Lesson object (and its children)
        from types import StringType,IntType, UnicodeType
        
        expected_results = [[('pobjid', 'ROOT'), 
                             ('period', '830-910'), 
                             ('dow', 'MO'), 
                             ('objid', '1.1'), 
                             ('objtype', 'Lesson')]]


                
        _results = self.of.dumpobj(['Lesson'])
        results = []
        for result in _results:
            result.pop('id')
            results.append([(k,v) for k,v in result.iteritems() if type(v) in [IntType,StringType,UnicodeType]])

        expected_results.sort()
        results.sort()

        self.assertListEqual(expected_results,results)
        
    def test_filter_on_student(self):
        
        # only report on the Student object and its children
        from types import StringType,IntType, UnicodeType
        
        expected_results = [[('pobjid', 'ROOT'), 
                             ('objid', 'booker'), 
                             ('objtype', 'Student'), 
                             ('nationality', 'british')]]
                
        _results = self.of.dumpobj(['Student'])
        results = []
        for result in _results:
            result.pop('id')
            results.append([(k,v) for k,v in result.iteritems() if type(v) in [IntType,StringType,UnicodeType]])

        expected_results.sort()
        results.sort()

        self.assertListEqual(expected_results,results)
开发者ID:burtnolej,项目名称:hungrycrayon,代码行数:94,代码来源:test_misc_utils_objectfactory.py


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