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


Python ObjFactory.query方法代码示例

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


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

示例1: Test_SchoolSched_schdule_load_1lesson

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

    def setUp(self):
        self.database = Database('htmlparser')
        self.of = ObjFactory(True)
        
        f = "/home/burtnolej/Development/pythonapps3/clean/apps/schoolscheduler/schedule.html" 
        self.schedule = htmlschedule_slice(f,num_periods=1,num_students=1,num_days=1)

        schedule_load(self.schedule, self.of, self.database)
        
    def test_schdload_lesson(self):
        schedule_load(self.schedule, self.of, self.database)
        
        exp_res = ['0.0.0']
        exp_res.sort()
        
        _res = self.of.query('lesson')
        
        
        _resstr =  [str(_r) for _r in _res]
        _resstr.sort()
        
        self.assertListEqual(exp_res, _resstr)

        
    def test_schdload_subject(self):
        schedule_load(self.schedule, self.of, self.database)
        
        _res = self.of.query('subject')        
        _resstr =  [str(_r) for _r in _res] 
        
        _resstr.sort()
        
        self.assertListEqual(['MOVEMENT'],
                             _resstr)
        
    def test_schdload_objtype(self):
        schedule_load(self.schedule, self.of, self.database)
        
        exp_res = ['period','student','dow','lessontype','subject','lesson']
        exp_res.sort()
        
        _res = self.of.query('objtype')        
        _resstr =  [str(_r) for _r in _res] 
        
        _resstr.sort()
        
        self.assertListEqual(exp_res,_resstr)
开发者ID:burtnolej,项目名称:hungrycrayon,代码行数:51,代码来源:test_schoolscheduler.py

示例2: Test_ObjFramework_2_records_same_cls

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

示例3: Test_ObjFramework_Database

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

示例4: Test_SchoolSched_htmlschedule_slice_2periods_1student_persist

# 需要导入模块: from misc_utils_objectfactory import ObjFactory [as 别名]
# 或者: from misc_utils_objectfactory.ObjFactory import query [as 别名]
class Test_SchoolSched_htmlschedule_slice_2periods_1student_persist(unittest.TestCase):
    
    def setUp(self):
        filename = "/home/burtnolej/Development/pythonapps3/clean/apps/schoolscheduler/schedule.html"
        self.schedule = htmlschedule_slice(filename,
                                           num_periods = 2,
                                           num_students = 1)
        
        self.database = Database('htmlparser')
        self.of = ObjFactory(True)
        
        schedule_load(self.schedule,self.of,self.database)
        
    def test_content_subject(self):
        
        exp_res = ['MOVEMENT', 'CHESS', 'CORE','STEM','YOGA','ART','READING PERIOD','SCIENCE']

        res = [str(res) for res in self.of.query('subject')]
        self.assertListEqual(res,exp_res)
        
    def test_content_teacher(self):
        
        exp_res = ['RAHUL', 'NATHANIEL']
        res = [str(res) for res in self.of.query('teacher')]
        self.assertListEqual(res,exp_res)
        
    def test_content_student(self):
        
        exp_res = ['NATHANIEL']
        res = [str(res) for res in self.of.query('student')]
        self.assertListEqual(res,exp_res)
        
    def test_content_userdefid(self):
        
        exp_res = ['0.0.0','0.1.0','0.2.0','0.3.0','0.4.0',
                   '0.0.1','0.1.1','0.2.1','0.3.1','0.4.1']
        res = [str(res) for res in self.of.query('userdefid')]
        self.assertListEqual(res,exp_res) 
        
    def test_content_lessontype(self):
        
        exp_res = ['other','break','edu']
        res = [str(res) for res in self.of.query('lessontype')]
        self.assertListEqual(res,exp_res)  
开发者ID:burtnolej,项目名称:hungrycrayon,代码行数:46,代码来源:test_schoolscheduler_htmlparser.py

示例5: Test_ObjFramework_Database_Derived

# 需要导入模块: from misc_utils_objectfactory import ObjFactory [as 别名]
# 或者: from misc_utils_objectfactory.ObjFactory import query [as 别名]
class Test_ObjFramework_Database_Derived(unittest.TestCase):
    # pass in a subclass of dbtblgeneric as a baseclass; testing a bug found
    # in schoolschedulewizard
    
    class Dummy(dbtblgeneric):
        pass
    
    def setUp(self):
        self.of = ObjFactory(True)
        self.database = Database('foobar')
        self.foobar= self.of.new(self.Dummy,
                                 'DBLesson',
                                 objid='dblesson0',
                                 constructor='datamembers',
                                 modname=__name__,
                                 database=self.database,
                                 dm={'student':'booker',
                                     'period':2,
                                     'dow':3})
        
    def test_num_obj_created(self):
        self.assertEquals(len(self.of.query('DBLesson')),1)
开发者ID:burtnolej,项目名称:hungrycrayon,代码行数:24,代码来源:test_misc_utils_objectfactory.py

示例6: Test_ObjFramework_2_class

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

示例7: Test_addrecord

# 需要导入模块: from misc_utils_objectfactory import ObjFactory [as 别名]
# 或者: from misc_utils_objectfactory.ObjFactory import query [as 别名]
class Test_addrecord(unittest.TestCase):
    
    def setUp(self):
        
        self.dbname='service_add_record'
        self.database = Database(self.dbname)
        self.of = ObjFactory(True)
        self.enums = sswizard_utils.setenums(dow="all",prep=-1,database=self.database)
        self.prepmap = sswizard_utils._loadprepmapper(self.database)

        args = dict(database=self.database,refdatabase=self.database,saveversion=1,of=self.of,enums=self.enums)
        ssviewer_utils.dataset_load(**args)

    def test_(self):
        
        # test that a new object is added into of store with the correct userobjid
        
        expected_result = 'Stan.Math.Tuesday.830-910'
        
        datamembers = {'student':'Nathaniel',
                       'teacher':'Stan',
                       'subject':'Math',
                       'period':'830-910',
                       'recordtype':'academic',
                       'dow':'Tuesday'}
        args = dict(database=self.database,refdatabase=self.database,prepmap=self.prepmap,of=self.of,enums=self.enums,
                    datamembers=datamembers)
    
        ssviewer_utils.dataset_add(**args)
    
        self.assertEqual(self.of.object_get('lesson',datamembers['userobjid']).session.name,
                         expected_result)
        
    def test_internal_dict(self):
        
        # test that the internal datamembers/dm dict has the correct keys by asserting correct values
        # and comparing keys vs a recovered record
        
        expected_result = {'status': 'master', 'prep': 5, 'recordtype': 'subject', 
                           'period': '830-910', 'substatus': 'complete', 'source': 'manual', 'session': 
                           'Stan.Math.Tuesday.830-910', 'adult': 'Stan', 'student': 'Nathaniel', 'objtype': 
                           'lesson', 'dow': u'TU', 'userobjid': '1.2.1.2.4', 'subject': 'Math'} 
        
        datamembers = {'student':'Nathaniel',
                       'teacher':'Stan',
                       'subject':'Math',
                       'period':'830-910',
                       'recordtype':'subject',
                       'dow':'Tuesday'}
        
        args = dict(database=self.database,refdatabase=self.database,prepmap=self.prepmap,of=self.of,enums=self.enums,
                    datamembers=datamembers)
    
        ssviewer_utils.dataset_add(**args)
    
        obj_recovered = self.of.query('lesson')[0].dm.keys()
        obj_add = self.of.query('lesson')[1].dm.keys()
             
        obj_recovered.sort()
        obj_add.sort()
        
        # test keys
        self.assertListEqual(obj_recovered,obj_add)
        
        obj = self.of.object_get('lesson',datamembers['userobjid'])
            
        obj.dm.pop("id")
        
        # test values
        self.assertEqual(obj.dm,expected_result)
        
    def test_internal_attr(self):
        
        # check the member attr values and that the keys are the same between recovered and added objects
        datamembers = {'student':'Nathaniel',
                       'teacher':'Stan',
                       'subject':'Math',
                       'period':'830-910',
                       'recordtype':'subject',
                       'dow':'Tuesday'}
        
        args = dict(database=self.database,refdatabase=self.database,prepmap=self.prepmap,of=self.of,enums=self.enums,
                    datamembers=datamembers)
    
        obj = ssviewer_utils.dataset_add(**args)
        
        self.assertEquals(obj.adult.name,'Stan')
        self.assertEquals(obj.dow.name,'TU')
        self.assertTrue(hasattr(obj,'id'))
        self.assertEquals(obj.objtype.name,'lesson')
        self.assertEquals(obj.period.name,'830-910')
        self.assertEquals(obj.prep.name,5)
        self.assertEquals(obj.recordtype.name,'subject')
        self.assertEquals(obj.session.name,'Stan.Math.Tuesday.830-910')
        self.assertEquals(obj.source.name,'manual')
        self.assertEquals(obj.status.name,'master')
        self.assertEquals(obj.student.name,'Nathaniel')
        self.assertEquals(obj.subject.name,'Math')
        self.assertEquals(obj.substatus.name,'complete')
        self.assertEquals(obj.userobjid.name,'1.2.1.2.4')
#.........这里部分代码省略.........
开发者ID:burtnolej,项目名称:hungrycrayon,代码行数:103,代码来源:test_ssviewer_utils.py

示例8: SSViewer

# 需要导入模块: from misc_utils_objectfactory import ObjFactory [as 别名]
# 或者: from misc_utils_objectfactory.ObjFactory import query [as 别名]
class SSViewer(object):

    def __init__(self,dbname,refdbname):
        
        log.log(thisfuncname(),3,msg="initialize",dbname=dbname,refdbname=refdbname)

        self.colorpalette = dict(wp=green,subject=lightblue,ap='yellow',
                                 Movement=pink,ELA=salmon,Humanities=lightyellow,
                                 Counseling=lightgreen,Math=lightturquoise, 
                                 Music=lightblue,STEM=lavender,Art=purple,History=pink,
                                 Science=darkgreen,Core=karky,Chess=burgundy,
                                 computertime='darkgrey',Speech=darkburgundy,
                                 Student_News=darkgrey,Computer_Time=brown,
                                 Activity_Period=mauve,Melissa=navyblue,Amelia=darkgreen,
                                 Samantha=darkyellow, Alexa=paleblue, Paraic=palegreen, 
                                 Francisco=cerise,Rahul=verydarkgrey,Dylan=verydarkgrey,
                                 Moira=verydarkgrey,Issey=verydarkgrey, Daryl=verydarkgrey, 
                                 Karolina=verydarkgrey)
        

        self.fontpalette = dict(Amelia=green,Paraic=darkgreen,Stan=lavender,
                                Samantha=lightgreen,Alexa=blue,Francisco=purple,
                                Melissa=lightblue,Rahul=dirtyyellow,Dylan=dirtyyellow, 
                                Moira=dirtyyellow,Issey=dirtyyellow, Daryl=dirtyyellow, 
                                Karolina=dirtyyellow,Chess=pink,Student_News=lightyellow,
                                subject=blue)
        
        
        self.of = ObjFactory(True)
        
        self.refdatabase = Database(refdbname)        
        self.dbname = dbname
        self.database = Database(self.dbname)
        self.lastsaveversion=0

    def _color_get_multi(self,values):
        bgs=[]
        fgs=[]
        for value in values:
            _bg,_fg = self.color_get(value)
            bgs.append(_bg)
            fgs.append(_fg)
        return(bgs,fgs)
    
    def color_get(self,value):
        
        bg = lightgrey
        fg = black
            
        try:
            int(value)
            value = str(value)
        except ValueError:
            pass
        
        if value.count(" ") > 0:
            value= value.replace(" ","_")
            
        if value.count("[") == 1 and value.count("]") == 1:
            bg = red
        
        if value.count(".") > 0:
            value = value.split(".")[0]
            
        if self.colorpalette.has_key(value):
            bg = self.colorpalette[value]
            
        if self.fontpalette.has_key(value):
            fg = self.fontpalette[value]
            
            
        return(bg,fg)        
        
    def viewer(self,yaxis_type,xaxis_type,ztypes, source_type,source_value,
               conflicts_only='N',constraints=None,wratio=None,formatson=False):
            
        if source_value == "":
            source_objs = self.of.query(source_type)
        else:
            source_objs = [self.of.object_get(source_type,source_value)]
            
        xaxis_obj = self.of.query(xaxis_type)
        yaxis_obj = self.of.query(yaxis_type)
        
        count=0
        yaxis_enum = {}
        for _yaxis_obj in yaxis_obj:
            yaxis_enum[_yaxis_obj.name] = count
            count+=1
        
        xaxis_enum = self.enums[xaxis_type]['name2enum']
        
        values = [] # contains the values displayed on the grid

        values = [['']]    
        for yval in yaxis_enum.keys():
            values[0].append(yval)
            
        for xval in xaxis_enum.keys():
            values.append([xval])
#.........这里部分代码省略.........
开发者ID:burtnolej,项目名称:hungrycrayon,代码行数:103,代码来源:ssviewer_headless.py

示例9: Test_SchoolSched_schdule_load

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

    def setUp(self):
        self.database = Database('htmlparser')
        self.of = ObjFactory(True)
        
        f = "/home/burtnolej/Development/pythonapps3/clean/apps/schoolscheduler/schedule.html" 
        self.schedule = htmlschedule_slice(f,num_periods=2,num_students=1)

        schedule_load(self.schedule, self.of, self.database)
        
    def test_schdload_lesson(self):
        schedule_load(self.schedule, self.of, self.database)
        
        exp_res = ['0.0.0','0.1.0','0.2.0','0.3.0','0.4.0','0.0.1','0.1.1','0.2.1','0.3.1','0.4.1']
        exp_res.sort()
        
        _res = self.of.query('lesson')
        
        
        _resstr =  [str(_r) for _r in _res]
        _resstr.sort()
        
        self.assertListEqual(exp_res, _resstr)

        
    def test_schdload_subject(self):
        schedule_load(self.schedule, self.of, self.database)
        
        _res = self.of.query('subject')        
        _resstr =  [str(_r) for _r in _res] 
        
        _resstr.sort()
        
        self.assertListEqual(['ART','CHESS','CORE','MOVEMENT','READING PERIOD','SCIENCE','STEM','YOGA'],
                             _resstr)
        
    def test_schdload_teacher(self):
        schedule_load(self.schedule, self.of, self.database)
        
        _res = self.of.query('teacher')        
        _resstr =  [str(_r) for _r in _res] 
        
        _resstr.sort()
        
        self.assertListEqual(['NATHANIEL','RAHUL'],
                             _resstr)
        
    def test_schdload_dow(self):
        schedule_load(self.schedule, self.of, self.database)
        
        _res = self.of.query('dow')        
        _resstr =  [str(_r) for _r in _res] 
        
        _resstr.sort()
        
        self.assertListEqual(['Friday','Monday','Thursday','Tuesday','Wednesday'],
                             _resstr)
        
    def test_schdload_objtype(self):
        schedule_load(self.schedule, self.of, self.database)
        
        exp_res = ['period','student','dow','lessontype','subject','lesson','teacher']
        exp_res.sort()
        
        _res = self.of.query('objtype')        
        _resstr =  [str(_r) for _r in _res] 
        
        _resstr.sort()
        
        self.assertListEqual(exp_res,_resstr)
开发者ID:burtnolej,项目名称:hungrycrayon,代码行数:73,代码来源:test_schoolscheduler.py


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