[Modeling-cvs] ProjectModeling/Modeling/tests test_EditingContext_Global_Inheritance.py,1.19,1.20
Status: Abandoned
Brought to you by:
sbigaret
From: <sbi...@us...> - 2003-08-22 04:41:50
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests In directory sc8-pr-cvs1:/tmp/cvs-serv14599/Modeling/tests Modified Files: test_EditingContext_Global_Inheritance.py Log Message: Added Oracle to the list of supported db + support for DateFrom through DCOracle2.Timestamp Index: test_EditingContext_Global_Inheritance.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global_Inheritance.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** test_EditingContext_Global_Inheritance.py 3 Aug 2003 11:15:39 -0000 1.19 --- test_EditingContext_Global_Inheritance.py 20 Aug 2003 20:41:12 -0000 1.20 *************** *** 57,60 **** --- 57,62 ---- from StoreEmployees.Holidays import Holidays + from mx import DateTime + DateFrom=DateTime.DateFrom class TestEditingContext_Global_Inheritance(unittest.TestCase): *************** *** 376,380 **** ec=EditingContext() holidays=Holidays() - from mx.DateTime import DateFrom holidays.setStartDate(DateFrom('2003-07-01 08:00')) holidays.setEndDate(DateFrom('2003-08-01 08:00')) --- 378,381 ---- *************** *** 406,410 **** emp=self._test_10_class_employee() emp.setLastName('Test10'); emp.setFirstName('T.') - from mx.DateTime import DateFrom holidays=Holidays() holidays.setStartDate(DateFrom('2003-07-01 08:00')) --- 407,410 ---- *************** *** 521,525 **** emp.addToHolidays(holidays) - from mx.DateTime import DateFrom holidays.setStartDate(DateFrom('2003-07-02 08:00')) ec.saveChanges() --- 521,524 ---- *************** *** 562,566 **** emp=self._test_11_class_employee() emp.setLastName('Test11'); emp.setFirstName('T.') - from mx.DateTime import DateFrom holidays=Holidays() holidays.setStartDate(DateFrom('2003-07-01 08:00')) --- 561,564 ---- *************** *** 608,612 **** emp.removeFromHolidays(holidays) h2=Holidays() - from mx.DateTime import DateFrom sd2=DateFrom('2003-01-01 01:00') ed2=DateFrom('2003-02-02 02:00') --- 606,609 ---- *************** *** 735,739 **** ! def reinitDB(): """ Reinitializes the database: recreates the db's schema needed for these tests --- 732,736 ---- ! def reinitDB(database_cfg): """ Reinitializes the database: recreates the db's schema needed for these tests *************** *** 765,768 **** --- 762,768 ---- print 'error: %s'%str(exc) + if database_cfg=='Oracle.cfg': + sqlExpr.setStatement("alter session set nls_date_format = 'YYYY-MM-DD HH24:mi:ss'") + channel.evaluateExpression(sqlExpr) # Store *************** *** 848,852 **** is altered: tables are dropped, then they are re-created along with constraints for PKs and FKs and PK support (sequences) ! -d sets the database adaptor to use: Postgresql (default), MySQL or SQLite """ % prgName if exitStatus is not None: --- 848,853 ---- is altered: tables are dropped, then they are re-created along with constraints for PKs and FKs and PK support (sequences) ! -d sets the database adaptor to use: Postgresql (default), MySQL, Oracle or ! or SQLite """ % prgName if exitStatus is not None: *************** *** 873,877 **** if k=='-p': profile=1; continue if k=='-d': ! if v not in ('Postgresql', 'MySQL', 'SQLite'): usage(me, 1) database_cfg='%s.cfg'%v continue --- 874,878 ---- if k=='-p': profile=1; continue if k=='-d': ! if v not in ('Postgresql', 'MySQL', 'Oracle', 'SQLite'): usage(me, 1) database_cfg='%s.cfg'%v continue *************** *** 888,894 **** model.entityNamed('Holidays').attributeNamed('endDate').setExternalType('DATETIME') utils.enable_model_cache_and_compute() ! if reinitDB_flag: reinitDB(); return if profile: --- 889,908 ---- model.entityNamed('Holidays').attributeNamed('endDate').setExternalType('DATETIME') + # Oracle specifics: change TIMESTAMP to DATE + if database_cfg=='Oracle.cfg': + model.entityNamed('Holidays').attributeNamed('startDate').setExternalType('DATE') + model.entityNamed('Holidays').attributeNamed('endDate').setExternalType('DATE') + global DateFrom + def OracleDateFrom(str): + date, time=str.split() + yyyy,mm,dd=map(lambda s: int(s), date.split('-')) + h,m=map(lambda s: int(s), time.split(':')) + s=0 + import DCOracle2 + return DCOracle2.Timestamp(yyyy,mm,dd,h,m,s) + DateFrom=OracleDateFrom utils.enable_model_cache_and_compute() ! if reinitDB_flag: reinitDB(database_cfg); return if profile: *************** *** 903,907 **** suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestEditingContext_Global_Inheritance, ! "test_")) return suite --- 917,921 ---- suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestEditingContext_Global_Inheritance, ! "test")) return suite *************** *** 910,911 **** --- 924,926 ---- #errs = utils.run_suite(test_suite()) sys.exit(errs and 1 or 0) + W |