本文整理匯總了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)
示例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)
示例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)