mò )á¸Ec@sYdZdkZdkZdkZeiƒdklZlZlZlZdk Z dk l Z l Z dk l Z dklZlZdfd„ƒYZedƒZed d ƒZd „Zed d d d ƒZed ddd ƒZdefd„ƒYZeddddƒZdeifd„ƒYZd„ZedjoeiddƒndS(sWDateIndex unit tests. $Id: test_DateIndex.py 40218 2005-11-18 14:39:19Z andreasjung $ N(sdatesdatetimestzinfos timedelta(sIntTypes FloatType(sDateTime(s DateIndexsLocaltDummycBs,tZd„Zd„Zd„Zd„ZRS(NcCs||_||_dS(N(tnametselft_nametdatet_date(RRR((tT/data/zmath/zope/lib/python/Products/PluginIndexes/DateIndex/tests/test_DateIndex.pyt__init__"s cCs|iS(N(RR(R((RR'scCs|iS(N(RR(R((RR*scCsd|it|iƒfS(Ns(RRtstrR(R((Rt__str__-s(t__name__t __module__RRRR (((RR s   ithoursicCs/d|iƒ}|o|t|ƒ7}n|S(Ni(tdttweekdayt days_to_got timedelta(R R((Rtfirst_sunday_on_or_after5siii it USTimeZonecBs5tZd„Zd„Zd„Zd„Zd„ZRS(NcCs1td|ƒ|_||_||_||_dS(NR (RR Rt stdoffsettreprnametstdnametdstname(RR RRR((RRCs  cCs|iS(N(RR(R((Rt__repr__IscCs&|i|ƒo |iSn|iSdS(N(RtdstR RR(RR ((RttznameLs cCs|i|i|ƒS(N(RRRR (RR ((Rt utcoffsetRscCs¬|djp|idjotSn|i|jpt‚ttid|i ƒƒ}tt id|i ƒƒ}||iddƒjo |jnot SntSdS(Ntyearttzinfo(R tNoneRtZERORtAssertionErrorRtDSTSTARTtreplaceRtstarttDSTENDtendtHOUR(RR R$R"((RRUs*(R R RRRRR(((RRAs     iûÿÿÿtEasterntESTtEDTtDI_TestscBsYtZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d „Z RS( NcCs8dtdtƒfdtdtdƒƒfdtdtdƒƒfdtd td ƒƒfd td td ƒƒfdtd td ƒƒfdtddƒfdtddƒfdtdtdddƒƒfdtdtddddddƒƒfdtdtdddddddtƒƒff |_tdƒ|_ hd d!<|_ hdtdƒ<|_ hdhd"td ƒ<d#d$<<|_ hdhd"td ƒ<d#d%<<|_ hdhd"tdƒtd ƒf<d#d&<<|_hdd<|_hdt<|_hdd<|_hdd<|_dS('Nitaitbitcs2002-05-08 15:16:17itds2032-05-08 15:16:17ites2062-05-08 15:16:17iitff 1072742620.0iiôÁð?itgiòi thiii tiiRRtbari{tquerytrangetmintmaxsmin:max(RRtDateTimeRtdatetimeR&Rt_valuest DateIndext_indext _noop_reqt_requestt_min_reqt_max_reqt _range_reqt _zero_reqt _none_reqt _float_reqt_int_req(R((RtsetUpnsÿ **6cCs1x*|iD]\}}|ii||ƒq WdS(N(RR:tktvR<t index_object(RRGRH((Rt_populateIndexŒs cCsŸ|ii|ƒ\}}t|dƒo|iƒ}n|i|dƒ|it |ƒt |ƒd||fƒx'|D]\}}|i ||jƒqxWdS(NtkeysRs%s | %s(sdate(RR<t _apply_indextreqtresulttusedthasattrRKtfailUnlessEqualtlentexpectedValuesRGRHt failUnless(RRMRSRORNRHRG((Rt _checkApplys cCst|ƒttfjo&ti|ƒd \}}}}}n»t|ƒt jo#|i ƒd \}}}}}n…t|ƒt joI|idjo|idtƒ}n|iƒd \}}}}}n)|idƒiƒd \}}}}}|d|d|d|d|S(NiRtUTCi iii<(ttypeR t FloatTypetIntTypettimetgmtimetyrtmotdythrtmnRt timetupleR9RRR!tLocalt utctimetuplettoZonetparts(RR R_R`R^R\R]((Rt_convertšs&##(cCsydkl}dkl}dkl}dkl}dkl}||tƒ||tƒ||tƒ||tƒdS(N(s IDateIndex(sIPluggableIndex(s ISortIndex(sIUniqueValueIndex(s verifyClass(t!Products.PluginIndexes.interfacest IDateIndextIPluggableIndext ISortIndextIUniqueValueIndextzope.interface.verifyt verifyClassR;(RRmRjRhRiRk((Rttest_z3interfaces§s        cCsI|i}|it|ƒdƒ|it|iƒƒdƒ|i|idƒdjƒg}|i|id|ƒ|jƒ|i dƒ|i|i dƒƒ|i |i dƒƒ|it|i dƒƒdƒ|i|ihdd<ƒdjƒ|i|igƒ|i|igƒ|i|igƒ|i|igƒdS(NiiÒRtfootzedi90(RR<temptyRQRRtreferencedObjectsRTtgetEntryForObjectRtmarkertunindex_objectthasUniqueValuesFortfailIft uniqueValuesRLRUR>R?R@RA(RRtRq((Rt test_empty³s  %cCsû|iƒ|i}|i}|it|ƒt|ƒdƒ|it|iƒƒt|ƒdƒ|i |i dƒdjƒg}|i |i d|ƒ|jƒ|i dƒxP|D]H\}}|iƒo/|i|ii |ƒ|i|iƒƒƒq·q·W|it|idƒƒt|ƒdƒ|i |i|iƒdjƒ|i|i|dd!ƒ|i|i|dd!|dƒ|i|i|dd!|dd!ƒ|i|i|dƒ|i|i|dgƒ|i|i|d gƒdS( NiiiÒRiiiii(RRJR:tvaluesR<tindexRQRRRrRTRsRRtRuRGRHRRfRxRLR=RUR>R?R@RARDRE(RR{RzRHRtRG((Rttest_retrievalÉs,    &   )"%c Cs«|i}|i}t|_|iƒx|dD]s\} }|i ƒi ƒd \} }}}}| d|d|d|d|}|i|ii| ƒ|ƒq0WdS(Ni ii iii<(RR:RzR<R{tFalsetindex_naive_time_as_localRJRGRHRRcR\R]R^R_R`tvalRQRs( RR{R`RR_R^RzR]RHR\RG((Rttest_naive_convert_to_utcæs     %&cCsi|i}|i}|iƒ|i|i|dgƒ|iddƒ|i d|i ƒi ƒjƒdS(s: DateIndex would hand back spurious entries when used as a sort_index, because it previously was not removing entries from the _unindex when indexing an object with a value of None. The catalog consults a sort_index's documentToKeyMap() to build the brains. iN( RR:RzR<R{RJRURERIRRwtdocumentToKeyMapRK(RR{Rz((Rt test_removalòs   ( R R RFRJRURfRnRyR|R€R‚(((RR)ms     cCs&tiƒ}|ititƒƒ|S(N(tunittestt TestSuitetsuitetaddTestt makeSuiteR)(R…((Rt test_suites t__main__t defaultTestRˆ(t__doc__RƒtTestingtZope2tstartupR9RRRRZttypesRYRXR8t*Products.PluginIndexes.DateIndex.DateIndexR;RbRRR%RR R#RR&tTestCaseR)RˆR tmain(RYRR;RƒR9RRbR)R%RXR RR#RRRRR8RRŒR&RˆRZ((Rt?s*        (”