當前位置: 首頁>>代碼示例>>Python>>正文


Python ObjFactory.query_advanced方法代碼示例

本文整理匯總了Python中misc_utils_objectfactory.ObjFactory.query_advanced方法的典型用法代碼示例。如果您正苦於以下問題:Python ObjFactory.query_advanced方法的具體用法?Python ObjFactory.query_advanced怎麽用?Python ObjFactory.query_advanced使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在misc_utils_objectfactory.ObjFactory的用法示例。


在下文中一共展示了ObjFactory.query_advanced方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Test_update

# 需要導入模塊: from misc_utils_objectfactory import ObjFactory [as 別名]
# 或者: from misc_utils_objectfactory.ObjFactory import query_advanced [as 別名]
class Test_update(unittest.TestCase):
    
    def setUp(self):
        
        self.dbname='test_ssviewer_util_add'
        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,keepversion=True)
        ssviewer_utils.dataset_load(**args)

    def test_update_subject(self):

        expected_results = [[u'master', u'complete', u'academic', u'830-910', u'WE', u'dbinsert', u'[Dylan,Francisco].Movement.Wednesday.830-910', u'[Dylan,Francisco]', u'Nathaniel', 5, u'1.4.1.None.8', u'Movement'], 
                            [u'master', u'complete', u'academic', u'830-910', u'WE', u'dbinsert', u'[Dylan,Francisco].Movement.Wednesday.830-910', u'[Dylan,Francisco]', u'Nathaniel', 5, u'1.4.1.None.8', u'ELA']]
        
        obj = self.of.query_advanced("lesson",[('period','830-910'),
                                          ('dow','WE')])
        
        obj[0].update(self.of,'subject','ELA')
        
        with self.database:
            _,rows,_ = tbl_rows_get(self.database,"lesson",
                                    fields = ['status', 'substatus', 'recordtype', 'period', 'dow', 'source', 'session', 'teacher', 'student', 'prep', 'userobjid', 'subject'],
                                    whereclause = [["period","=","\"830-910\""],
                                                   ["dow","=","\"WE\""]])
            
        self.assertListEqual(rows,expected_results)


    def test_update_adult(self):
        
        expected_results = [[u'master', u'complete', u'academic', u'830-910', u'WE', u'dbinsert', u'[Dylan,Francisco].Movement.Wednesday.830-910', u'[Dylan,Francisco]', u'Nathaniel', 5, u'1.4.1.None.8', u'Movement'], 
                            [u'master', u'complete', u'academic', u'830-910', u'WE', u'dbinsert', u'[Dylan,Francisco].Movement.Wednesday.830-910', u'Amelia', u'Nathaniel', 5, u'1.4.1.None.8', u'Movement']]
        
        obj = self.of.query_advanced("lesson",[('period','830-910'),
                                          ('dow','WE')])
        
        obj[0].update(self.of,'teacher','Amelia')
        
        with self.database:
            _,rows,_ = tbl_rows_get(self.database,"lesson",
                                    fields = ['status', 'substatus', 'recordtype', 'period', 'dow', 'source', 'session', 'teacher', 'student', 'prep', 'userobjid', 'subject'],
                                    whereclause = [["period","=","\"830-910\""],
                                                   ["dow","=","\"WE\""]])
            
        self.assertListEqual(rows,expected_results)
        
    def tearDown(self):
        shutil.copyfile(self.dbname+".sqlite.backup",self.dbname + ".sqlite")
開發者ID:burtnolej,項目名稱:hungrycrayon,代碼行數:55,代碼來源:test_ssviewer_utils.py

示例2: Test_ObjFrameworkDumpNested

# 需要導入模塊: from misc_utils_objectfactory import ObjFactory [as 別名]
# 或者: from misc_utils_objectfactory.ObjFactory import query_advanced [as 別名]
class Test_ObjFrameworkDumpNested(unittest.TestCase):

    def setUp(self):
        self.of = ObjFactory(True)
        self.obj1 = self.of.new(GenericBase,
                    'Student',
                    objid='booker',
                    nationality='british',
                    modname=__name__)
        
        self.of.new(GenericBase,
                    'Student',
                    objid='fred',
                    age=23,
                    nationality='british',
                    modname=__name__)
        
        self.of.new(GenericBase,
                    'Student',
                    objid='fred',
                    age=35,
                    nationality='irish',
                    modname=__name__)
        
        self.of.new(GenericBase,
                    'Classroom',
                    objid='1a',
                    nationality='swedish',
                    modname=__name__)
        

    def tearDown(self):
        self.of.reset()
        
    '''def test_1clause(self):
        results = self.of.query_advanced('Student',[('objid','booker')])
        
        self.assertEquals(len(results),1)
        self.assertEquals(results[0].objid,'booker')
        
    def test_2clause(self):
        results = self.of.query_advanced('Student',[('nationality','british'),
                                                    ('objid','fred')])
        
        self.assertEquals(len(results),1)
        self.assertEquals(results[0].age,23)'''
        
        
    def test_update_then_search(self):
        ''' make sure that search picks up the updated version of the object '''
        
        self.obj1.nationality = 'indian'
        results = self.of.query_advanced('Student',[('objid','booker')])
        
        self.assertEquals(results[0].nationality,'indian')
開發者ID:burtnolej,項目名稱:hungrycrayon,代碼行數:57,代碼來源:test_misc_utils_objectfactory.py


注:本文中的misc_utils_objectfactory.ObjFactory.query_advanced方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。