123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914 |
- # -*- coding: utf-8 -*-
- from __future__ import unicode_literals
- from datetime import datetime, date
- import unittest
- from six import PY2
- from dateutil import tz
- from dateutil.rrule import (
- rrule, rruleset, rrulestr,
- YEARLY, MONTHLY, WEEKLY, DAILY,
- HOURLY, MINUTELY, SECONDLY,
- MO, TU, WE, TH, FR, SA, SU
- )
- from freezegun import freeze_time
- import pytest
- @pytest.mark.rrule
- class RRuleTest(unittest.TestCase):
- def _rrulestr_reverse_test(self, rule):
- """
- Call with an `rrule` and it will test that `str(rrule)` generates a
- string which generates the same `rrule` as the input when passed to
- `rrulestr()`
- """
- rr_str = str(rule)
- rrulestr_rrule = rrulestr(rr_str)
- self.assertEqual(list(rule), list(rrulestr_rrule))
- def testStrAppendRRULEToken(self):
- # `_rrulestr_reverse_test` does not check if the "RRULE:" prefix
- # property is appended properly, so give it a dedicated test
- self.assertEqual(str(rrule(YEARLY,
- count=5,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- "DTSTART:19970902T090000\n"
- "RRULE:FREQ=YEARLY;COUNT=5")
- rr_str = (
- 'DTSTART:19970105T083000\nRRULE:FREQ=YEARLY;INTERVAL=2'
- )
- self.assertEqual(str(rrulestr(rr_str)), rr_str)
- def testYearly(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1998, 9, 2, 9, 0),
- datetime(1999, 9, 2, 9, 0)])
- def testYearlyInterval(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- interval=2,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1999, 9, 2, 9, 0),
- datetime(2001, 9, 2, 9, 0)])
- def testYearlyIntervalLarge(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- interval=100,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(2097, 9, 2, 9, 0),
- datetime(2197, 9, 2, 9, 0)])
- def testYearlyByMonth(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- bymonth=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 2, 9, 0),
- datetime(1998, 3, 2, 9, 0),
- datetime(1999, 1, 2, 9, 0)])
- def testYearlyByMonthDay(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- bymonthday=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 3, 9, 0),
- datetime(1997, 10, 1, 9, 0),
- datetime(1997, 10, 3, 9, 0)])
- def testYearlyByMonthAndMonthDay(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(5, 7),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 5, 9, 0),
- datetime(1998, 1, 7, 9, 0),
- datetime(1998, 3, 5, 9, 0)])
- def testYearlyByWeekDay(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 9, 9, 0)])
- def testYearlyByNWeekDay(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 25, 9, 0),
- datetime(1998, 1, 6, 9, 0),
- datetime(1998, 12, 31, 9, 0)])
- def testYearlyByNWeekDayLarge(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byweekday=(TU(3), TH(-3)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 11, 9, 0),
- datetime(1998, 1, 20, 9, 0),
- datetime(1998, 12, 17, 9, 0)])
- def testYearlyByMonthAndWeekDay(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 1, 6, 9, 0),
- datetime(1998, 1, 8, 9, 0)])
- def testYearlyByMonthAndNWeekDay(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 6, 9, 0),
- datetime(1998, 1, 29, 9, 0),
- datetime(1998, 3, 3, 9, 0)])
- def testYearlyByMonthAndNWeekDayLarge(self):
- # This is interesting because the TH(-3) ends up before
- # the TU(3).
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(3), TH(-3)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 15, 9, 0),
- datetime(1998, 1, 20, 9, 0),
- datetime(1998, 3, 12, 9, 0)])
- def testYearlyByMonthDayAndWeekDay(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 2, 3, 9, 0),
- datetime(1998, 3, 3, 9, 0)])
- def testYearlyByMonthAndMonthDayAndWeekDay(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 3, 3, 9, 0),
- datetime(2001, 3, 1, 9, 0)])
- def testYearlyByYearDay(self):
- self.assertEqual(list(rrule(YEARLY,
- count=4,
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 31, 9, 0),
- datetime(1998, 1, 1, 9, 0),
- datetime(1998, 4, 10, 9, 0),
- datetime(1998, 7, 19, 9, 0)])
- def testYearlyByYearDayNeg(self):
- self.assertEqual(list(rrule(YEARLY,
- count=4,
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 31, 9, 0),
- datetime(1998, 1, 1, 9, 0),
- datetime(1998, 4, 10, 9, 0),
- datetime(1998, 7, 19, 9, 0)])
- def testYearlyByMonthAndYearDay(self):
- self.assertEqual(list(rrule(YEARLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 10, 9, 0),
- datetime(1998, 7, 19, 9, 0),
- datetime(1999, 4, 10, 9, 0),
- datetime(1999, 7, 19, 9, 0)])
- def testYearlyByMonthAndYearDayNeg(self):
- self.assertEqual(list(rrule(YEARLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 10, 9, 0),
- datetime(1998, 7, 19, 9, 0),
- datetime(1999, 4, 10, 9, 0),
- datetime(1999, 7, 19, 9, 0)])
- def testYearlyByWeekNo(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byweekno=20,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 5, 11, 9, 0),
- datetime(1998, 5, 12, 9, 0),
- datetime(1998, 5, 13, 9, 0)])
- def testYearlyByWeekNoAndWeekDay(self):
- # That's a nice one. The first days of week number one
- # may be in the last year.
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byweekno=1,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 29, 9, 0),
- datetime(1999, 1, 4, 9, 0),
- datetime(2000, 1, 3, 9, 0)])
- def testYearlyByWeekNoAndWeekDayLarge(self):
- # Another nice test. The last days of week number 52/53
- # may be in the next year.
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byweekno=52,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 28, 9, 0),
- datetime(1998, 12, 27, 9, 0),
- datetime(2000, 1, 2, 9, 0)])
- def testYearlyByWeekNoAndWeekDayLast(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byweekno=-1,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 28, 9, 0),
- datetime(1999, 1, 3, 9, 0),
- datetime(2000, 1, 2, 9, 0)])
- def testYearlyByEaster(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byeaster=0,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 12, 9, 0),
- datetime(1999, 4, 4, 9, 0),
- datetime(2000, 4, 23, 9, 0)])
- def testYearlyByEasterPos(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byeaster=1,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 13, 9, 0),
- datetime(1999, 4, 5, 9, 0),
- datetime(2000, 4, 24, 9, 0)])
- def testYearlyByEasterNeg(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byeaster=-1,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 11, 9, 0),
- datetime(1999, 4, 3, 9, 0),
- datetime(2000, 4, 22, 9, 0)])
- def testYearlyByWeekNoAndWeekDay53(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byweekno=53,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 12, 28, 9, 0),
- datetime(2004, 12, 27, 9, 0),
- datetime(2009, 12, 28, 9, 0)])
- def testYearlyByHour(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byhour=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 0),
- datetime(1998, 9, 2, 6, 0),
- datetime(1998, 9, 2, 18, 0)])
- def testYearlyByMinute(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 6),
- datetime(1997, 9, 2, 9, 18),
- datetime(1998, 9, 2, 9, 6)])
- def testYearlyBySecond(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0, 6),
- datetime(1997, 9, 2, 9, 0, 18),
- datetime(1998, 9, 2, 9, 0, 6)])
- def testYearlyByHourAndMinute(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 6),
- datetime(1997, 9, 2, 18, 18),
- datetime(1998, 9, 2, 6, 6)])
- def testYearlyByHourAndSecond(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byhour=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 0, 6),
- datetime(1997, 9, 2, 18, 0, 18),
- datetime(1998, 9, 2, 6, 0, 6)])
- def testYearlyByMinuteAndSecond(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 6, 6),
- datetime(1997, 9, 2, 9, 6, 18),
- datetime(1997, 9, 2, 9, 18, 6)])
- def testYearlyByHourAndMinuteAndSecond(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 6, 6),
- datetime(1997, 9, 2, 18, 6, 18),
- datetime(1997, 9, 2, 18, 18, 6)])
- def testYearlyBySetPos(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- bymonthday=15,
- byhour=(6, 18),
- bysetpos=(3, -3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 11, 15, 18, 0),
- datetime(1998, 2, 15, 6, 0),
- datetime(1998, 11, 15, 18, 0)])
- def testMonthly(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 10, 2, 9, 0),
- datetime(1997, 11, 2, 9, 0)])
- def testMonthlyInterval(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- interval=2,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 11, 2, 9, 0),
- datetime(1998, 1, 2, 9, 0)])
- def testMonthlyIntervalLarge(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- interval=18,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1999, 3, 2, 9, 0),
- datetime(2000, 9, 2, 9, 0)])
- def testMonthlyByMonth(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- bymonth=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 2, 9, 0),
- datetime(1998, 3, 2, 9, 0),
- datetime(1999, 1, 2, 9, 0)])
- def testMonthlyByMonthDay(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- bymonthday=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 3, 9, 0),
- datetime(1997, 10, 1, 9, 0),
- datetime(1997, 10, 3, 9, 0)])
- def testMonthlyByMonthAndMonthDay(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(5, 7),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 5, 9, 0),
- datetime(1998, 1, 7, 9, 0),
- datetime(1998, 3, 5, 9, 0)])
- def testMonthlyByWeekDay(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 9, 9, 0)])
- # Third Monday of the month
- self.assertEqual(rrule(MONTHLY,
- byweekday=(MO(+3)),
- dtstart=datetime(1997, 9, 1)).between(datetime(1997, 9, 1),
- datetime(1997, 12, 1)),
- [datetime(1997, 9, 15, 0, 0),
- datetime(1997, 10, 20, 0, 0),
- datetime(1997, 11, 17, 0, 0)])
- def testMonthlyByNWeekDay(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 25, 9, 0),
- datetime(1997, 10, 7, 9, 0)])
- def testMonthlyByNWeekDayLarge(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byweekday=(TU(3), TH(-3)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 11, 9, 0),
- datetime(1997, 9, 16, 9, 0),
- datetime(1997, 10, 16, 9, 0)])
- def testMonthlyByMonthAndWeekDay(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 1, 6, 9, 0),
- datetime(1998, 1, 8, 9, 0)])
- def testMonthlyByMonthAndNWeekDay(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 6, 9, 0),
- datetime(1998, 1, 29, 9, 0),
- datetime(1998, 3, 3, 9, 0)])
- def testMonthlyByMonthAndNWeekDayLarge(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(3), TH(-3)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 15, 9, 0),
- datetime(1998, 1, 20, 9, 0),
- datetime(1998, 3, 12, 9, 0)])
- def testMonthlyByMonthDayAndWeekDay(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 2, 3, 9, 0),
- datetime(1998, 3, 3, 9, 0)])
- def testMonthlyByMonthAndMonthDayAndWeekDay(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 3, 3, 9, 0),
- datetime(2001, 3, 1, 9, 0)])
- def testMonthlyByYearDay(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=4,
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 31, 9, 0),
- datetime(1998, 1, 1, 9, 0),
- datetime(1998, 4, 10, 9, 0),
- datetime(1998, 7, 19, 9, 0)])
- def testMonthlyByYearDayNeg(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=4,
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 31, 9, 0),
- datetime(1998, 1, 1, 9, 0),
- datetime(1998, 4, 10, 9, 0),
- datetime(1998, 7, 19, 9, 0)])
- def testMonthlyByMonthAndYearDay(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 10, 9, 0),
- datetime(1998, 7, 19, 9, 0),
- datetime(1999, 4, 10, 9, 0),
- datetime(1999, 7, 19, 9, 0)])
- def testMonthlyByMonthAndYearDayNeg(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 10, 9, 0),
- datetime(1998, 7, 19, 9, 0),
- datetime(1999, 4, 10, 9, 0),
- datetime(1999, 7, 19, 9, 0)])
- def testMonthlyByWeekNo(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byweekno=20,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 5, 11, 9, 0),
- datetime(1998, 5, 12, 9, 0),
- datetime(1998, 5, 13, 9, 0)])
- def testMonthlyByWeekNoAndWeekDay(self):
- # That's a nice one. The first days of week number one
- # may be in the last year.
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byweekno=1,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 29, 9, 0),
- datetime(1999, 1, 4, 9, 0),
- datetime(2000, 1, 3, 9, 0)])
- def testMonthlyByWeekNoAndWeekDayLarge(self):
- # Another nice test. The last days of week number 52/53
- # may be in the next year.
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byweekno=52,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 28, 9, 0),
- datetime(1998, 12, 27, 9, 0),
- datetime(2000, 1, 2, 9, 0)])
- def testMonthlyByWeekNoAndWeekDayLast(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byweekno=-1,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 28, 9, 0),
- datetime(1999, 1, 3, 9, 0),
- datetime(2000, 1, 2, 9, 0)])
- def testMonthlyByWeekNoAndWeekDay53(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byweekno=53,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 12, 28, 9, 0),
- datetime(2004, 12, 27, 9, 0),
- datetime(2009, 12, 28, 9, 0)])
- def testMonthlyByEaster(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byeaster=0,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 12, 9, 0),
- datetime(1999, 4, 4, 9, 0),
- datetime(2000, 4, 23, 9, 0)])
- def testMonthlyByEasterPos(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byeaster=1,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 13, 9, 0),
- datetime(1999, 4, 5, 9, 0),
- datetime(2000, 4, 24, 9, 0)])
- def testMonthlyByEasterNeg(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byeaster=-1,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 11, 9, 0),
- datetime(1999, 4, 3, 9, 0),
- datetime(2000, 4, 22, 9, 0)])
- def testMonthlyByHour(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byhour=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 0),
- datetime(1997, 10, 2, 6, 0),
- datetime(1997, 10, 2, 18, 0)])
- def testMonthlyByMinute(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 6),
- datetime(1997, 9, 2, 9, 18),
- datetime(1997, 10, 2, 9, 6)])
- def testMonthlyBySecond(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0, 6),
- datetime(1997, 9, 2, 9, 0, 18),
- datetime(1997, 10, 2, 9, 0, 6)])
- def testMonthlyByHourAndMinute(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 6),
- datetime(1997, 9, 2, 18, 18),
- datetime(1997, 10, 2, 6, 6)])
- def testMonthlyByHourAndSecond(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byhour=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 0, 6),
- datetime(1997, 9, 2, 18, 0, 18),
- datetime(1997, 10, 2, 6, 0, 6)])
- def testMonthlyByMinuteAndSecond(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 6, 6),
- datetime(1997, 9, 2, 9, 6, 18),
- datetime(1997, 9, 2, 9, 18, 6)])
- def testMonthlyByHourAndMinuteAndSecond(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 6, 6),
- datetime(1997, 9, 2, 18, 6, 18),
- datetime(1997, 9, 2, 18, 18, 6)])
- def testMonthlyBySetPos(self):
- self.assertEqual(list(rrule(MONTHLY,
- count=3,
- bymonthday=(13, 17),
- byhour=(6, 18),
- bysetpos=(3, -3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 13, 18, 0),
- datetime(1997, 9, 17, 6, 0),
- datetime(1997, 10, 13, 18, 0)])
- def testWeekly(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 9, 9, 0),
- datetime(1997, 9, 16, 9, 0)])
- def testWeeklyInterval(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- interval=2,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 16, 9, 0),
- datetime(1997, 9, 30, 9, 0)])
- def testWeeklyIntervalLarge(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- interval=20,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1998, 1, 20, 9, 0),
- datetime(1998, 6, 9, 9, 0)])
- def testWeeklyByMonth(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- bymonth=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 6, 9, 0),
- datetime(1998, 1, 13, 9, 0),
- datetime(1998, 1, 20, 9, 0)])
- def testWeeklyByMonthDay(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- bymonthday=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 3, 9, 0),
- datetime(1997, 10, 1, 9, 0),
- datetime(1997, 10, 3, 9, 0)])
- def testWeeklyByMonthAndMonthDay(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(5, 7),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 5, 9, 0),
- datetime(1998, 1, 7, 9, 0),
- datetime(1998, 3, 5, 9, 0)])
- def testWeeklyByWeekDay(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 9, 9, 0)])
- def testWeeklyByNWeekDay(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 9, 9, 0)])
- def testWeeklyByMonthAndWeekDay(self):
- # This test is interesting, because it crosses the year
- # boundary in a weekly period to find day '1' as a
- # valid recurrence.
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 1, 6, 9, 0),
- datetime(1998, 1, 8, 9, 0)])
- def testWeeklyByMonthAndNWeekDay(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 1, 6, 9, 0),
- datetime(1998, 1, 8, 9, 0)])
- def testWeeklyByMonthDayAndWeekDay(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 2, 3, 9, 0),
- datetime(1998, 3, 3, 9, 0)])
- def testWeeklyByMonthAndMonthDayAndWeekDay(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 3, 3, 9, 0),
- datetime(2001, 3, 1, 9, 0)])
- def testWeeklyByYearDay(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=4,
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 31, 9, 0),
- datetime(1998, 1, 1, 9, 0),
- datetime(1998, 4, 10, 9, 0),
- datetime(1998, 7, 19, 9, 0)])
- def testWeeklyByYearDayNeg(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=4,
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 31, 9, 0),
- datetime(1998, 1, 1, 9, 0),
- datetime(1998, 4, 10, 9, 0),
- datetime(1998, 7, 19, 9, 0)])
- def testWeeklyByMonthAndYearDay(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=4,
- bymonth=(1, 7),
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 7, 19, 9, 0),
- datetime(1999, 1, 1, 9, 0),
- datetime(1999, 7, 19, 9, 0)])
- def testWeeklyByMonthAndYearDayNeg(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=4,
- bymonth=(1, 7),
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 7, 19, 9, 0),
- datetime(1999, 1, 1, 9, 0),
- datetime(1999, 7, 19, 9, 0)])
- def testWeeklyByWeekNo(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byweekno=20,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 5, 11, 9, 0),
- datetime(1998, 5, 12, 9, 0),
- datetime(1998, 5, 13, 9, 0)])
- def testWeeklyByWeekNoAndWeekDay(self):
- # That's a nice one. The first days of week number one
- # may be in the last year.
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byweekno=1,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 29, 9, 0),
- datetime(1999, 1, 4, 9, 0),
- datetime(2000, 1, 3, 9, 0)])
- def testWeeklyByWeekNoAndWeekDayLarge(self):
- # Another nice test. The last days of week number 52/53
- # may be in the next year.
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byweekno=52,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 28, 9, 0),
- datetime(1998, 12, 27, 9, 0),
- datetime(2000, 1, 2, 9, 0)])
- def testWeeklyByWeekNoAndWeekDayLast(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byweekno=-1,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 28, 9, 0),
- datetime(1999, 1, 3, 9, 0),
- datetime(2000, 1, 2, 9, 0)])
- def testWeeklyByWeekNoAndWeekDay53(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byweekno=53,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 12, 28, 9, 0),
- datetime(2004, 12, 27, 9, 0),
- datetime(2009, 12, 28, 9, 0)])
- def testWeeklyByEaster(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byeaster=0,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 12, 9, 0),
- datetime(1999, 4, 4, 9, 0),
- datetime(2000, 4, 23, 9, 0)])
- def testWeeklyByEasterPos(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byeaster=1,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 13, 9, 0),
- datetime(1999, 4, 5, 9, 0),
- datetime(2000, 4, 24, 9, 0)])
- def testWeeklyByEasterNeg(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byeaster=-1,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 11, 9, 0),
- datetime(1999, 4, 3, 9, 0),
- datetime(2000, 4, 22, 9, 0)])
- def testWeeklyByHour(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byhour=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 0),
- datetime(1997, 9, 9, 6, 0),
- datetime(1997, 9, 9, 18, 0)])
- def testWeeklyByMinute(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 6),
- datetime(1997, 9, 2, 9, 18),
- datetime(1997, 9, 9, 9, 6)])
- def testWeeklyBySecond(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0, 6),
- datetime(1997, 9, 2, 9, 0, 18),
- datetime(1997, 9, 9, 9, 0, 6)])
- def testWeeklyByHourAndMinute(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 6),
- datetime(1997, 9, 2, 18, 18),
- datetime(1997, 9, 9, 6, 6)])
- def testWeeklyByHourAndSecond(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byhour=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 0, 6),
- datetime(1997, 9, 2, 18, 0, 18),
- datetime(1997, 9, 9, 6, 0, 6)])
- def testWeeklyByMinuteAndSecond(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 6, 6),
- datetime(1997, 9, 2, 9, 6, 18),
- datetime(1997, 9, 2, 9, 18, 6)])
- def testWeeklyByHourAndMinuteAndSecond(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 6, 6),
- datetime(1997, 9, 2, 18, 6, 18),
- datetime(1997, 9, 2, 18, 18, 6)])
- def testWeeklyBySetPos(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- byweekday=(TU, TH),
- byhour=(6, 18),
- bysetpos=(3, -3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 0),
- datetime(1997, 9, 4, 6, 0),
- datetime(1997, 9, 9, 18, 0)])
- def testDaily(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 3, 9, 0),
- datetime(1997, 9, 4, 9, 0)])
- def testDailyInterval(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- interval=2,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 6, 9, 0)])
- def testDailyIntervalLarge(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- interval=92,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 12, 3, 9, 0),
- datetime(1998, 3, 5, 9, 0)])
- def testDailyByMonth(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- bymonth=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 1, 2, 9, 0),
- datetime(1998, 1, 3, 9, 0)])
- def testDailyByMonthDay(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- bymonthday=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 3, 9, 0),
- datetime(1997, 10, 1, 9, 0),
- datetime(1997, 10, 3, 9, 0)])
- def testDailyByMonthAndMonthDay(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(5, 7),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 5, 9, 0),
- datetime(1998, 1, 7, 9, 0),
- datetime(1998, 3, 5, 9, 0)])
- def testDailyByWeekDay(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 9, 9, 0)])
- def testDailyByNWeekDay(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 9, 9, 0)])
- def testDailyByMonthAndWeekDay(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 1, 6, 9, 0),
- datetime(1998, 1, 8, 9, 0)])
- def testDailyByMonthAndNWeekDay(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 1, 6, 9, 0),
- datetime(1998, 1, 8, 9, 0)])
- def testDailyByMonthDayAndWeekDay(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 2, 3, 9, 0),
- datetime(1998, 3, 3, 9, 0)])
- def testDailyByMonthAndMonthDayAndWeekDay(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 3, 3, 9, 0),
- datetime(2001, 3, 1, 9, 0)])
- def testDailyByYearDay(self):
- self.assertEqual(list(rrule(DAILY,
- count=4,
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 31, 9, 0),
- datetime(1998, 1, 1, 9, 0),
- datetime(1998, 4, 10, 9, 0),
- datetime(1998, 7, 19, 9, 0)])
- def testDailyByYearDayNeg(self):
- self.assertEqual(list(rrule(DAILY,
- count=4,
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 31, 9, 0),
- datetime(1998, 1, 1, 9, 0),
- datetime(1998, 4, 10, 9, 0),
- datetime(1998, 7, 19, 9, 0)])
- def testDailyByMonthAndYearDay(self):
- self.assertEqual(list(rrule(DAILY,
- count=4,
- bymonth=(1, 7),
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 7, 19, 9, 0),
- datetime(1999, 1, 1, 9, 0),
- datetime(1999, 7, 19, 9, 0)])
- def testDailyByMonthAndYearDayNeg(self):
- self.assertEqual(list(rrule(DAILY,
- count=4,
- bymonth=(1, 7),
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 9, 0),
- datetime(1998, 7, 19, 9, 0),
- datetime(1999, 1, 1, 9, 0),
- datetime(1999, 7, 19, 9, 0)])
- def testDailyByWeekNo(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byweekno=20,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 5, 11, 9, 0),
- datetime(1998, 5, 12, 9, 0),
- datetime(1998, 5, 13, 9, 0)])
- def testDailyByWeekNoAndWeekDay(self):
- # That's a nice one. The first days of week number one
- # may be in the last year.
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byweekno=1,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 29, 9, 0),
- datetime(1999, 1, 4, 9, 0),
- datetime(2000, 1, 3, 9, 0)])
- def testDailyByWeekNoAndWeekDayLarge(self):
- # Another nice test. The last days of week number 52/53
- # may be in the next year.
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byweekno=52,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 28, 9, 0),
- datetime(1998, 12, 27, 9, 0),
- datetime(2000, 1, 2, 9, 0)])
- def testDailyByWeekNoAndWeekDayLast(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byweekno=-1,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 28, 9, 0),
- datetime(1999, 1, 3, 9, 0),
- datetime(2000, 1, 2, 9, 0)])
- def testDailyByWeekNoAndWeekDay53(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byweekno=53,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 12, 28, 9, 0),
- datetime(2004, 12, 27, 9, 0),
- datetime(2009, 12, 28, 9, 0)])
- def testDailyByEaster(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byeaster=0,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 12, 9, 0),
- datetime(1999, 4, 4, 9, 0),
- datetime(2000, 4, 23, 9, 0)])
- def testDailyByEasterPos(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byeaster=1,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 13, 9, 0),
- datetime(1999, 4, 5, 9, 0),
- datetime(2000, 4, 24, 9, 0)])
- def testDailyByEasterNeg(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byeaster=-1,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 11, 9, 0),
- datetime(1999, 4, 3, 9, 0),
- datetime(2000, 4, 22, 9, 0)])
- def testDailyByHour(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byhour=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 0),
- datetime(1997, 9, 3, 6, 0),
- datetime(1997, 9, 3, 18, 0)])
- def testDailyByMinute(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 6),
- datetime(1997, 9, 2, 9, 18),
- datetime(1997, 9, 3, 9, 6)])
- def testDailyBySecond(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0, 6),
- datetime(1997, 9, 2, 9, 0, 18),
- datetime(1997, 9, 3, 9, 0, 6)])
- def testDailyByHourAndMinute(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 6),
- datetime(1997, 9, 2, 18, 18),
- datetime(1997, 9, 3, 6, 6)])
- def testDailyByHourAndSecond(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byhour=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 0, 6),
- datetime(1997, 9, 2, 18, 0, 18),
- datetime(1997, 9, 3, 6, 0, 6)])
- def testDailyByMinuteAndSecond(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 6, 6),
- datetime(1997, 9, 2, 9, 6, 18),
- datetime(1997, 9, 2, 9, 18, 6)])
- def testDailyByHourAndMinuteAndSecond(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 6, 6),
- datetime(1997, 9, 2, 18, 6, 18),
- datetime(1997, 9, 2, 18, 18, 6)])
- def testDailyBySetPos(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- byhour=(6, 18),
- byminute=(15, 45),
- bysetpos=(3, -3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 15),
- datetime(1997, 9, 3, 6, 45),
- datetime(1997, 9, 3, 18, 15)])
- def testHourly(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 2, 10, 0),
- datetime(1997, 9, 2, 11, 0)])
- def testHourlyInterval(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- interval=2,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 2, 11, 0),
- datetime(1997, 9, 2, 13, 0)])
- def testHourlyIntervalLarge(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- interval=769,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 10, 4, 10, 0),
- datetime(1997, 11, 5, 11, 0)])
- def testHourlyByMonth(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- bymonth=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 0, 0),
- datetime(1998, 1, 1, 1, 0),
- datetime(1998, 1, 1, 2, 0)])
- def testHourlyByMonthDay(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- bymonthday=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 3, 0, 0),
- datetime(1997, 9, 3, 1, 0),
- datetime(1997, 9, 3, 2, 0)])
- def testHourlyByMonthAndMonthDay(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(5, 7),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 5, 0, 0),
- datetime(1998, 1, 5, 1, 0),
- datetime(1998, 1, 5, 2, 0)])
- def testHourlyByWeekDay(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 2, 10, 0),
- datetime(1997, 9, 2, 11, 0)])
- def testHourlyByNWeekDay(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 2, 10, 0),
- datetime(1997, 9, 2, 11, 0)])
- def testHourlyByMonthAndWeekDay(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 0, 0),
- datetime(1998, 1, 1, 1, 0),
- datetime(1998, 1, 1, 2, 0)])
- def testHourlyByMonthAndNWeekDay(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 0, 0),
- datetime(1998, 1, 1, 1, 0),
- datetime(1998, 1, 1, 2, 0)])
- def testHourlyByMonthDayAndWeekDay(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 0, 0),
- datetime(1998, 1, 1, 1, 0),
- datetime(1998, 1, 1, 2, 0)])
- def testHourlyByMonthAndMonthDayAndWeekDay(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 0, 0),
- datetime(1998, 1, 1, 1, 0),
- datetime(1998, 1, 1, 2, 0)])
- def testHourlyByYearDay(self):
- self.assertEqual(list(rrule(HOURLY,
- count=4,
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 31, 0, 0),
- datetime(1997, 12, 31, 1, 0),
- datetime(1997, 12, 31, 2, 0),
- datetime(1997, 12, 31, 3, 0)])
- def testHourlyByYearDayNeg(self):
- self.assertEqual(list(rrule(HOURLY,
- count=4,
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 31, 0, 0),
- datetime(1997, 12, 31, 1, 0),
- datetime(1997, 12, 31, 2, 0),
- datetime(1997, 12, 31, 3, 0)])
- def testHourlyByMonthAndYearDay(self):
- self.assertEqual(list(rrule(HOURLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 10, 0, 0),
- datetime(1998, 4, 10, 1, 0),
- datetime(1998, 4, 10, 2, 0),
- datetime(1998, 4, 10, 3, 0)])
- def testHourlyByMonthAndYearDayNeg(self):
- self.assertEqual(list(rrule(HOURLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 10, 0, 0),
- datetime(1998, 4, 10, 1, 0),
- datetime(1998, 4, 10, 2, 0),
- datetime(1998, 4, 10, 3, 0)])
- def testHourlyByWeekNo(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byweekno=20,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 5, 11, 0, 0),
- datetime(1998, 5, 11, 1, 0),
- datetime(1998, 5, 11, 2, 0)])
- def testHourlyByWeekNoAndWeekDay(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byweekno=1,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 29, 0, 0),
- datetime(1997, 12, 29, 1, 0),
- datetime(1997, 12, 29, 2, 0)])
- def testHourlyByWeekNoAndWeekDayLarge(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byweekno=52,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 28, 0, 0),
- datetime(1997, 12, 28, 1, 0),
- datetime(1997, 12, 28, 2, 0)])
- def testHourlyByWeekNoAndWeekDayLast(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byweekno=-1,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 28, 0, 0),
- datetime(1997, 12, 28, 1, 0),
- datetime(1997, 12, 28, 2, 0)])
- def testHourlyByWeekNoAndWeekDay53(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byweekno=53,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 12, 28, 0, 0),
- datetime(1998, 12, 28, 1, 0),
- datetime(1998, 12, 28, 2, 0)])
- def testHourlyByEaster(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byeaster=0,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 12, 0, 0),
- datetime(1998, 4, 12, 1, 0),
- datetime(1998, 4, 12, 2, 0)])
- def testHourlyByEasterPos(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byeaster=1,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 13, 0, 0),
- datetime(1998, 4, 13, 1, 0),
- datetime(1998, 4, 13, 2, 0)])
- def testHourlyByEasterNeg(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byeaster=-1,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 11, 0, 0),
- datetime(1998, 4, 11, 1, 0),
- datetime(1998, 4, 11, 2, 0)])
- def testHourlyByHour(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byhour=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 0),
- datetime(1997, 9, 3, 6, 0),
- datetime(1997, 9, 3, 18, 0)])
- def testHourlyByMinute(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 6),
- datetime(1997, 9, 2, 9, 18),
- datetime(1997, 9, 2, 10, 6)])
- def testHourlyBySecond(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0, 6),
- datetime(1997, 9, 2, 9, 0, 18),
- datetime(1997, 9, 2, 10, 0, 6)])
- def testHourlyByHourAndMinute(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 6),
- datetime(1997, 9, 2, 18, 18),
- datetime(1997, 9, 3, 6, 6)])
- def testHourlyByHourAndSecond(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byhour=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 0, 6),
- datetime(1997, 9, 2, 18, 0, 18),
- datetime(1997, 9, 3, 6, 0, 6)])
- def testHourlyByMinuteAndSecond(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 6, 6),
- datetime(1997, 9, 2, 9, 6, 18),
- datetime(1997, 9, 2, 9, 18, 6)])
- def testHourlyByHourAndMinuteAndSecond(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 6, 6),
- datetime(1997, 9, 2, 18, 6, 18),
- datetime(1997, 9, 2, 18, 18, 6)])
- def testHourlyBySetPos(self):
- self.assertEqual(list(rrule(HOURLY,
- count=3,
- byminute=(15, 45),
- bysecond=(15, 45),
- bysetpos=(3, -3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 15, 45),
- datetime(1997, 9, 2, 9, 45, 15),
- datetime(1997, 9, 2, 10, 15, 45)])
- def testMinutely(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 2, 9, 1),
- datetime(1997, 9, 2, 9, 2)])
- def testMinutelyInterval(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- interval=2,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 2, 9, 2),
- datetime(1997, 9, 2, 9, 4)])
- def testMinutelyIntervalLarge(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- interval=1501,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 3, 10, 1),
- datetime(1997, 9, 4, 11, 2)])
- def testMinutelyByMonth(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- bymonth=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 0, 0),
- datetime(1998, 1, 1, 0, 1),
- datetime(1998, 1, 1, 0, 2)])
- def testMinutelyByMonthDay(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- bymonthday=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 3, 0, 0),
- datetime(1997, 9, 3, 0, 1),
- datetime(1997, 9, 3, 0, 2)])
- def testMinutelyByMonthAndMonthDay(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(5, 7),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 5, 0, 0),
- datetime(1998, 1, 5, 0, 1),
- datetime(1998, 1, 5, 0, 2)])
- def testMinutelyByWeekDay(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 2, 9, 1),
- datetime(1997, 9, 2, 9, 2)])
- def testMinutelyByNWeekDay(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 2, 9, 1),
- datetime(1997, 9, 2, 9, 2)])
- def testMinutelyByMonthAndWeekDay(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 0, 0),
- datetime(1998, 1, 1, 0, 1),
- datetime(1998, 1, 1, 0, 2)])
- def testMinutelyByMonthAndNWeekDay(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 0, 0),
- datetime(1998, 1, 1, 0, 1),
- datetime(1998, 1, 1, 0, 2)])
- def testMinutelyByMonthDayAndWeekDay(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 0, 0),
- datetime(1998, 1, 1, 0, 1),
- datetime(1998, 1, 1, 0, 2)])
- def testMinutelyByMonthAndMonthDayAndWeekDay(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 0, 0),
- datetime(1998, 1, 1, 0, 1),
- datetime(1998, 1, 1, 0, 2)])
- def testMinutelyByYearDay(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=4,
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 31, 0, 0),
- datetime(1997, 12, 31, 0, 1),
- datetime(1997, 12, 31, 0, 2),
- datetime(1997, 12, 31, 0, 3)])
- def testMinutelyByYearDayNeg(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=4,
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 31, 0, 0),
- datetime(1997, 12, 31, 0, 1),
- datetime(1997, 12, 31, 0, 2),
- datetime(1997, 12, 31, 0, 3)])
- def testMinutelyByMonthAndYearDay(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=4,
- bymonth=(4, 7),
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 10, 0, 0),
- datetime(1998, 4, 10, 0, 1),
- datetime(1998, 4, 10, 0, 2),
- datetime(1998, 4, 10, 0, 3)])
- def testMinutelyByMonthAndYearDayNeg(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=4,
- bymonth=(4, 7),
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 10, 0, 0),
- datetime(1998, 4, 10, 0, 1),
- datetime(1998, 4, 10, 0, 2),
- datetime(1998, 4, 10, 0, 3)])
- def testMinutelyByWeekNo(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byweekno=20,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 5, 11, 0, 0),
- datetime(1998, 5, 11, 0, 1),
- datetime(1998, 5, 11, 0, 2)])
- def testMinutelyByWeekNoAndWeekDay(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byweekno=1,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 29, 0, 0),
- datetime(1997, 12, 29, 0, 1),
- datetime(1997, 12, 29, 0, 2)])
- def testMinutelyByWeekNoAndWeekDayLarge(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byweekno=52,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 28, 0, 0),
- datetime(1997, 12, 28, 0, 1),
- datetime(1997, 12, 28, 0, 2)])
- def testMinutelyByWeekNoAndWeekDayLast(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byweekno=-1,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 28, 0, 0),
- datetime(1997, 12, 28, 0, 1),
- datetime(1997, 12, 28, 0, 2)])
- def testMinutelyByWeekNoAndWeekDay53(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byweekno=53,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 12, 28, 0, 0),
- datetime(1998, 12, 28, 0, 1),
- datetime(1998, 12, 28, 0, 2)])
- def testMinutelyByEaster(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byeaster=0,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 12, 0, 0),
- datetime(1998, 4, 12, 0, 1),
- datetime(1998, 4, 12, 0, 2)])
- def testMinutelyByEasterPos(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byeaster=1,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 13, 0, 0),
- datetime(1998, 4, 13, 0, 1),
- datetime(1998, 4, 13, 0, 2)])
- def testMinutelyByEasterNeg(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byeaster=-1,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 11, 0, 0),
- datetime(1998, 4, 11, 0, 1),
- datetime(1998, 4, 11, 0, 2)])
- def testMinutelyByHour(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byhour=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 0),
- datetime(1997, 9, 2, 18, 1),
- datetime(1997, 9, 2, 18, 2)])
- def testMinutelyByMinute(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 6),
- datetime(1997, 9, 2, 9, 18),
- datetime(1997, 9, 2, 10, 6)])
- def testMinutelyBySecond(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0, 6),
- datetime(1997, 9, 2, 9, 0, 18),
- datetime(1997, 9, 2, 9, 1, 6)])
- def testMinutelyByHourAndMinute(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 6),
- datetime(1997, 9, 2, 18, 18),
- datetime(1997, 9, 3, 6, 6)])
- def testMinutelyByHourAndSecond(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byhour=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 0, 6),
- datetime(1997, 9, 2, 18, 0, 18),
- datetime(1997, 9, 2, 18, 1, 6)])
- def testMinutelyByMinuteAndSecond(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 6, 6),
- datetime(1997, 9, 2, 9, 6, 18),
- datetime(1997, 9, 2, 9, 18, 6)])
- def testMinutelyByHourAndMinuteAndSecond(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 6, 6),
- datetime(1997, 9, 2, 18, 6, 18),
- datetime(1997, 9, 2, 18, 18, 6)])
- def testMinutelyBySetPos(self):
- self.assertEqual(list(rrule(MINUTELY,
- count=3,
- bysecond=(15, 30, 45),
- bysetpos=(3, -3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0, 15),
- datetime(1997, 9, 2, 9, 0, 45),
- datetime(1997, 9, 2, 9, 1, 15)])
- def testSecondly(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0, 0),
- datetime(1997, 9, 2, 9, 0, 1),
- datetime(1997, 9, 2, 9, 0, 2)])
- def testSecondlyInterval(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- interval=2,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0, 0),
- datetime(1997, 9, 2, 9, 0, 2),
- datetime(1997, 9, 2, 9, 0, 4)])
- def testSecondlyIntervalLarge(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- interval=90061,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0, 0),
- datetime(1997, 9, 3, 10, 1, 1),
- datetime(1997, 9, 4, 11, 2, 2)])
- def testSecondlyByMonth(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- bymonth=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 0, 0, 0),
- datetime(1998, 1, 1, 0, 0, 1),
- datetime(1998, 1, 1, 0, 0, 2)])
- def testSecondlyByMonthDay(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- bymonthday=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 3, 0, 0, 0),
- datetime(1997, 9, 3, 0, 0, 1),
- datetime(1997, 9, 3, 0, 0, 2)])
- def testSecondlyByMonthAndMonthDay(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(5, 7),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 5, 0, 0, 0),
- datetime(1998, 1, 5, 0, 0, 1),
- datetime(1998, 1, 5, 0, 0, 2)])
- def testSecondlyByWeekDay(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0, 0),
- datetime(1997, 9, 2, 9, 0, 1),
- datetime(1997, 9, 2, 9, 0, 2)])
- def testSecondlyByNWeekDay(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0, 0),
- datetime(1997, 9, 2, 9, 0, 1),
- datetime(1997, 9, 2, 9, 0, 2)])
- def testSecondlyByMonthAndWeekDay(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 0, 0, 0),
- datetime(1998, 1, 1, 0, 0, 1),
- datetime(1998, 1, 1, 0, 0, 2)])
- def testSecondlyByMonthAndNWeekDay(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 0, 0, 0),
- datetime(1998, 1, 1, 0, 0, 1),
- datetime(1998, 1, 1, 0, 0, 2)])
- def testSecondlyByMonthDayAndWeekDay(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 0, 0, 0),
- datetime(1998, 1, 1, 0, 0, 1),
- datetime(1998, 1, 1, 0, 0, 2)])
- def testSecondlyByMonthAndMonthDayAndWeekDay(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 1, 0, 0, 0),
- datetime(1998, 1, 1, 0, 0, 1),
- datetime(1998, 1, 1, 0, 0, 2)])
- def testSecondlyByYearDay(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=4,
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 31, 0, 0, 0),
- datetime(1997, 12, 31, 0, 0, 1),
- datetime(1997, 12, 31, 0, 0, 2),
- datetime(1997, 12, 31, 0, 0, 3)])
- def testSecondlyByYearDayNeg(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=4,
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 31, 0, 0, 0),
- datetime(1997, 12, 31, 0, 0, 1),
- datetime(1997, 12, 31, 0, 0, 2),
- datetime(1997, 12, 31, 0, 0, 3)])
- def testSecondlyByMonthAndYearDay(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 10, 0, 0, 0),
- datetime(1998, 4, 10, 0, 0, 1),
- datetime(1998, 4, 10, 0, 0, 2),
- datetime(1998, 4, 10, 0, 0, 3)])
- def testSecondlyByMonthAndYearDayNeg(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 10, 0, 0, 0),
- datetime(1998, 4, 10, 0, 0, 1),
- datetime(1998, 4, 10, 0, 0, 2),
- datetime(1998, 4, 10, 0, 0, 3)])
- def testSecondlyByWeekNo(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byweekno=20,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 5, 11, 0, 0, 0),
- datetime(1998, 5, 11, 0, 0, 1),
- datetime(1998, 5, 11, 0, 0, 2)])
- def testSecondlyByWeekNoAndWeekDay(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byweekno=1,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 29, 0, 0, 0),
- datetime(1997, 12, 29, 0, 0, 1),
- datetime(1997, 12, 29, 0, 0, 2)])
- def testSecondlyByWeekNoAndWeekDayLarge(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byweekno=52,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 28, 0, 0, 0),
- datetime(1997, 12, 28, 0, 0, 1),
- datetime(1997, 12, 28, 0, 0, 2)])
- def testSecondlyByWeekNoAndWeekDayLast(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byweekno=-1,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 12, 28, 0, 0, 0),
- datetime(1997, 12, 28, 0, 0, 1),
- datetime(1997, 12, 28, 0, 0, 2)])
- def testSecondlyByWeekNoAndWeekDay53(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byweekno=53,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 12, 28, 0, 0, 0),
- datetime(1998, 12, 28, 0, 0, 1),
- datetime(1998, 12, 28, 0, 0, 2)])
- def testSecondlyByEaster(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byeaster=0,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 12, 0, 0, 0),
- datetime(1998, 4, 12, 0, 0, 1),
- datetime(1998, 4, 12, 0, 0, 2)])
- def testSecondlyByEasterPos(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byeaster=1,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 13, 0, 0, 0),
- datetime(1998, 4, 13, 0, 0, 1),
- datetime(1998, 4, 13, 0, 0, 2)])
- def testSecondlyByEasterNeg(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byeaster=-1,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 4, 11, 0, 0, 0),
- datetime(1998, 4, 11, 0, 0, 1),
- datetime(1998, 4, 11, 0, 0, 2)])
- def testSecondlyByHour(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byhour=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 0, 0),
- datetime(1997, 9, 2, 18, 0, 1),
- datetime(1997, 9, 2, 18, 0, 2)])
- def testSecondlyByMinute(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 6, 0),
- datetime(1997, 9, 2, 9, 6, 1),
- datetime(1997, 9, 2, 9, 6, 2)])
- def testSecondlyBySecond(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0, 6),
- datetime(1997, 9, 2, 9, 0, 18),
- datetime(1997, 9, 2, 9, 1, 6)])
- def testSecondlyByHourAndMinute(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 6, 0),
- datetime(1997, 9, 2, 18, 6, 1),
- datetime(1997, 9, 2, 18, 6, 2)])
- def testSecondlyByHourAndSecond(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byhour=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 0, 6),
- datetime(1997, 9, 2, 18, 0, 18),
- datetime(1997, 9, 2, 18, 1, 6)])
- def testSecondlyByMinuteAndSecond(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 6, 6),
- datetime(1997, 9, 2, 9, 6, 18),
- datetime(1997, 9, 2, 9, 18, 6)])
- def testSecondlyByHourAndMinuteAndSecond(self):
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 18, 6, 6),
- datetime(1997, 9, 2, 18, 6, 18),
- datetime(1997, 9, 2, 18, 18, 6)])
- def testSecondlyByHourAndMinuteAndSecondBug(self):
- # This explores a bug found by Mathieu Bridon.
- self.assertEqual(list(rrule(SECONDLY,
- count=3,
- bysecond=(0,),
- byminute=(1,),
- dtstart=datetime(2010, 3, 22, 12, 1))),
- [datetime(2010, 3, 22, 12, 1),
- datetime(2010, 3, 22, 13, 1),
- datetime(2010, 3, 22, 14, 1)])
- def testLongIntegers(self):
- if PY2: # There are no longs in python3
- self.assertEqual(list(rrule(MINUTELY,
- count=long(2),
- interval=long(2),
- bymonth=long(2),
- byweekday=long(3),
- byhour=long(6),
- byminute=long(6),
- bysecond=long(6),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 2, 5, 6, 6, 6),
- datetime(1998, 2, 12, 6, 6, 6)])
- self.assertEqual(list(rrule(YEARLY,
- count=long(2),
- bymonthday=long(5),
- byweekno=long(2),
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1998, 1, 5, 9, 0),
- datetime(2004, 1, 5, 9, 0)])
- def testHourlyBadRRule(self):
- """
- When `byhour` is specified with `freq=HOURLY`, there are certain
- combinations of `dtstart` and `byhour` which result in an rrule with no
- valid values.
- See https://github.com/dateutil/dateutil/issues/4
- """
- self.assertRaises(ValueError, rrule, HOURLY,
- **dict(interval=4, byhour=(7, 11, 15, 19),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testMinutelyBadRRule(self):
- """
- See :func:`testHourlyBadRRule` for details.
- """
- self.assertRaises(ValueError, rrule, MINUTELY,
- **dict(interval=12, byminute=(10, 11, 25, 39, 50),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testSecondlyBadRRule(self):
- """
- See :func:`testHourlyBadRRule` for details.
- """
- self.assertRaises(ValueError, rrule, SECONDLY,
- **dict(interval=10, bysecond=(2, 15, 37, 42, 59),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testMinutelyBadComboRRule(self):
- """
- Certain values of :param:`interval` in :class:`rrule`, when combined
- with certain values of :param:`byhour` create rules which apply to no
- valid dates. The library should detect this case in the iterator and
- raise a :exception:`ValueError`.
- """
- # In Python 2.7 you can use a context manager for this.
- def make_bad_rrule():
- list(rrule(MINUTELY, interval=120, byhour=(10, 12, 14, 16),
- count=2, dtstart=datetime(1997, 9, 2, 9, 0)))
- self.assertRaises(ValueError, make_bad_rrule)
- def testSecondlyBadComboRRule(self):
- """
- See :func:`testMinutelyBadComboRRule' for details.
- """
- # In Python 2.7 you can use a context manager for this.
- def make_bad_minute_rrule():
- list(rrule(SECONDLY, interval=360, byminute=(10, 28, 49),
- count=4, dtstart=datetime(1997, 9, 2, 9, 0)))
- def make_bad_hour_rrule():
- list(rrule(SECONDLY, interval=43200, byhour=(2, 10, 18, 23),
- count=4, dtstart=datetime(1997, 9, 2, 9, 0)))
- self.assertRaises(ValueError, make_bad_minute_rrule)
- self.assertRaises(ValueError, make_bad_hour_rrule)
- def testBadUntilCountRRule(self):
- """
- See rfc-5545 3.3.10 - This checks for the deprecation warning, and will
- eventually check for an error.
- """
- with pytest.warns(DeprecationWarning):
- rrule(DAILY, dtstart=datetime(1997, 9, 2, 9, 0),
- count=3, until=datetime(1997, 9, 4, 9, 0))
- def testUntilNotMatching(self):
- self.assertEqual(list(rrule(DAILY,
- dtstart=datetime(1997, 9, 2, 9, 0),
- until=datetime(1997, 9, 5, 8, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 3, 9, 0),
- datetime(1997, 9, 4, 9, 0)])
- def testUntilMatching(self):
- self.assertEqual(list(rrule(DAILY,
- dtstart=datetime(1997, 9, 2, 9, 0),
- until=datetime(1997, 9, 4, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 3, 9, 0),
- datetime(1997, 9, 4, 9, 0)])
- def testUntilSingle(self):
- self.assertEqual(list(rrule(DAILY,
- dtstart=datetime(1997, 9, 2, 9, 0),
- until=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0)])
- def testUntilEmpty(self):
- self.assertEqual(list(rrule(DAILY,
- dtstart=datetime(1997, 9, 2, 9, 0),
- until=datetime(1997, 9, 1, 9, 0))),
- [])
- def testUntilWithDate(self):
- self.assertEqual(list(rrule(DAILY,
- dtstart=datetime(1997, 9, 2, 9, 0),
- until=date(1997, 9, 5))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 3, 9, 0),
- datetime(1997, 9, 4, 9, 0)])
- def testWkStIntervalMO(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- interval=2,
- byweekday=(TU, SU),
- wkst=MO,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 7, 9, 0),
- datetime(1997, 9, 16, 9, 0)])
- def testWkStIntervalSU(self):
- self.assertEqual(list(rrule(WEEKLY,
- count=3,
- interval=2,
- byweekday=(TU, SU),
- wkst=SU,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 14, 9, 0),
- datetime(1997, 9, 16, 9, 0)])
- def testDTStartIsDate(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- dtstart=date(1997, 9, 2))),
- [datetime(1997, 9, 2, 0, 0),
- datetime(1997, 9, 3, 0, 0),
- datetime(1997, 9, 4, 0, 0)])
- def testDTStartWithMicroseconds(self):
- self.assertEqual(list(rrule(DAILY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0, 0, 500000))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 3, 9, 0),
- datetime(1997, 9, 4, 9, 0)])
- def testMaxYear(self):
- self.assertEqual(list(rrule(YEARLY,
- count=3,
- bymonth=2,
- bymonthday=31,
- dtstart=datetime(9997, 9, 2, 9, 0, 0))),
- [])
- def testGetItem(self):
- self.assertEqual(rrule(DAILY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0))[0],
- datetime(1997, 9, 2, 9, 0))
- def testGetItemNeg(self):
- self.assertEqual(rrule(DAILY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0))[-1],
- datetime(1997, 9, 4, 9, 0))
- def testGetItemSlice(self):
- self.assertEqual(rrule(DAILY,
- # count=3,
- dtstart=datetime(1997, 9, 2, 9, 0))[1:2],
- [datetime(1997, 9, 3, 9, 0)])
- def testGetItemSliceEmpty(self):
- self.assertEqual(rrule(DAILY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0))[:],
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 3, 9, 0),
- datetime(1997, 9, 4, 9, 0)])
- def testGetItemSliceStep(self):
- self.assertEqual(rrule(DAILY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0))[::-2],
- [datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 2, 9, 0)])
- def testCount(self):
- self.assertEqual(rrule(DAILY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0)).count(),
- 3)
- def testCountZero(self):
- self.assertEqual(rrule(YEARLY,
- count=0,
- dtstart=datetime(1997, 9, 2, 9, 0)).count(),
- 0)
- def testContains(self):
- rr = rrule(DAILY, count=3, dtstart=datetime(1997, 9, 2, 9, 0))
- self.assertEqual(datetime(1997, 9, 3, 9, 0) in rr, True)
- def testContainsNot(self):
- rr = rrule(DAILY, count=3, dtstart=datetime(1997, 9, 2, 9, 0))
- self.assertEqual(datetime(1997, 9, 3, 9, 0) not in rr, False)
- def testBefore(self):
- self.assertEqual(rrule(DAILY, # count=5
- dtstart=datetime(1997, 9, 2, 9, 0)).before(datetime(1997, 9, 5, 9, 0)),
- datetime(1997, 9, 4, 9, 0))
- def testBeforeInc(self):
- self.assertEqual(rrule(DAILY,
- #count=5,
- dtstart=datetime(1997, 9, 2, 9, 0))
- .before(datetime(1997, 9, 5, 9, 0), inc=True),
- datetime(1997, 9, 5, 9, 0))
- def testAfter(self):
- self.assertEqual(rrule(DAILY,
- #count=5,
- dtstart=datetime(1997, 9, 2, 9, 0))
- .after(datetime(1997, 9, 4, 9, 0)),
- datetime(1997, 9, 5, 9, 0))
- def testAfterInc(self):
- self.assertEqual(rrule(DAILY,
- #count=5,
- dtstart=datetime(1997, 9, 2, 9, 0))
- .after(datetime(1997, 9, 4, 9, 0), inc=True),
- datetime(1997, 9, 4, 9, 0))
- def testXAfter(self):
- self.assertEqual(list(rrule(DAILY,
- dtstart=datetime(1997, 9, 2, 9, 0))
- .xafter(datetime(1997, 9, 8, 9, 0), count=12)),
- [datetime(1997, 9, 9, 9, 0),
- datetime(1997, 9, 10, 9, 0),
- datetime(1997, 9, 11, 9, 0),
- datetime(1997, 9, 12, 9, 0),
- datetime(1997, 9, 13, 9, 0),
- datetime(1997, 9, 14, 9, 0),
- datetime(1997, 9, 15, 9, 0),
- datetime(1997, 9, 16, 9, 0),
- datetime(1997, 9, 17, 9, 0),
- datetime(1997, 9, 18, 9, 0),
- datetime(1997, 9, 19, 9, 0),
- datetime(1997, 9, 20, 9, 0)])
- def testXAfterInc(self):
- self.assertEqual(list(rrule(DAILY,
- dtstart=datetime(1997, 9, 2, 9, 0))
- .xafter(datetime(1997, 9, 8, 9, 0), count=12, inc=True)),
- [datetime(1997, 9, 8, 9, 0),
- datetime(1997, 9, 9, 9, 0),
- datetime(1997, 9, 10, 9, 0),
- datetime(1997, 9, 11, 9, 0),
- datetime(1997, 9, 12, 9, 0),
- datetime(1997, 9, 13, 9, 0),
- datetime(1997, 9, 14, 9, 0),
- datetime(1997, 9, 15, 9, 0),
- datetime(1997, 9, 16, 9, 0),
- datetime(1997, 9, 17, 9, 0),
- datetime(1997, 9, 18, 9, 0),
- datetime(1997, 9, 19, 9, 0)])
- def testBetween(self):
- self.assertEqual(rrule(DAILY,
- #count=5,
- dtstart=datetime(1997, 9, 2, 9, 0))
- .between(datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 6, 9, 0)),
- [datetime(1997, 9, 3, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 5, 9, 0)])
- def testBetweenInc(self):
- self.assertEqual(rrule(DAILY,
- #count=5,
- dtstart=datetime(1997, 9, 2, 9, 0))
- .between(datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 6, 9, 0), inc=True),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 3, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 5, 9, 0),
- datetime(1997, 9, 6, 9, 0)])
- def testCachePre(self):
- rr = rrule(DAILY, count=15, cache=True,
- dtstart=datetime(1997, 9, 2, 9, 0))
- self.assertEqual(list(rr),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 3, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 5, 9, 0),
- datetime(1997, 9, 6, 9, 0),
- datetime(1997, 9, 7, 9, 0),
- datetime(1997, 9, 8, 9, 0),
- datetime(1997, 9, 9, 9, 0),
- datetime(1997, 9, 10, 9, 0),
- datetime(1997, 9, 11, 9, 0),
- datetime(1997, 9, 12, 9, 0),
- datetime(1997, 9, 13, 9, 0),
- datetime(1997, 9, 14, 9, 0),
- datetime(1997, 9, 15, 9, 0),
- datetime(1997, 9, 16, 9, 0)])
- def testCachePost(self):
- rr = rrule(DAILY, count=15, cache=True,
- dtstart=datetime(1997, 9, 2, 9, 0))
- for x in rr: pass
- self.assertEqual(list(rr),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 3, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 5, 9, 0),
- datetime(1997, 9, 6, 9, 0),
- datetime(1997, 9, 7, 9, 0),
- datetime(1997, 9, 8, 9, 0),
- datetime(1997, 9, 9, 9, 0),
- datetime(1997, 9, 10, 9, 0),
- datetime(1997, 9, 11, 9, 0),
- datetime(1997, 9, 12, 9, 0),
- datetime(1997, 9, 13, 9, 0),
- datetime(1997, 9, 14, 9, 0),
- datetime(1997, 9, 15, 9, 0),
- datetime(1997, 9, 16, 9, 0)])
- def testCachePostInternal(self):
- rr = rrule(DAILY, count=15, cache=True,
- dtstart=datetime(1997, 9, 2, 9, 0))
- for x in rr: pass
- self.assertEqual(rr._cache,
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 3, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 5, 9, 0),
- datetime(1997, 9, 6, 9, 0),
- datetime(1997, 9, 7, 9, 0),
- datetime(1997, 9, 8, 9, 0),
- datetime(1997, 9, 9, 9, 0),
- datetime(1997, 9, 10, 9, 0),
- datetime(1997, 9, 11, 9, 0),
- datetime(1997, 9, 12, 9, 0),
- datetime(1997, 9, 13, 9, 0),
- datetime(1997, 9, 14, 9, 0),
- datetime(1997, 9, 15, 9, 0),
- datetime(1997, 9, 16, 9, 0)])
- def testCachePreContains(self):
- rr = rrule(DAILY, count=3, cache=True,
- dtstart=datetime(1997, 9, 2, 9, 0))
- self.assertEqual(datetime(1997, 9, 3, 9, 0) in rr, True)
- def testCachePostContains(self):
- rr = rrule(DAILY, count=3, cache=True,
- dtstart=datetime(1997, 9, 2, 9, 0))
- for x in rr: pass
- self.assertEqual(datetime(1997, 9, 3, 9, 0) in rr, True)
- def testStr(self):
- self.assertEqual(list(rrulestr(
- "DTSTART:19970902T090000\n"
- "RRULE:FREQ=YEARLY;COUNT=3\n"
- )),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1998, 9, 2, 9, 0),
- datetime(1999, 9, 2, 9, 0)])
- def testStrWithTZID(self):
- NYC = tz.gettz('America/New_York')
- self.assertEqual(list(rrulestr(
- "DTSTART;TZID=America/New_York:19970902T090000\n"
- "RRULE:FREQ=YEARLY;COUNT=3\n"
- )),
- [datetime(1997, 9, 2, 9, 0, tzinfo=NYC),
- datetime(1998, 9, 2, 9, 0, tzinfo=NYC),
- datetime(1999, 9, 2, 9, 0, tzinfo=NYC)])
- def testStrWithTZIDMapping(self):
- rrstr = ("DTSTART;TZID=Eastern:19970902T090000\n" +
- "RRULE:FREQ=YEARLY;COUNT=3")
- NYC = tz.gettz('America/New_York')
- rr = rrulestr(rrstr, tzids={'Eastern': NYC})
- exp = [datetime(1997, 9, 2, 9, 0, tzinfo=NYC),
- datetime(1998, 9, 2, 9, 0, tzinfo=NYC),
- datetime(1999, 9, 2, 9, 0, tzinfo=NYC)]
- self.assertEqual(list(rr), exp)
- def testStrWithTZIDCallable(self):
- rrstr = ('DTSTART;TZID=UTC+04:19970902T090000\n' +
- 'RRULE:FREQ=YEARLY;COUNT=3')
- TZ = tz.tzstr('UTC+04')
- def parse_tzstr(tzstr):
- if tzstr is None:
- raise ValueError('Invalid tzstr')
- return tz.tzstr(tzstr)
- rr = rrulestr(rrstr, tzids=parse_tzstr)
- exp = [datetime(1997, 9, 2, 9, 0, tzinfo=TZ),
- datetime(1998, 9, 2, 9, 0, tzinfo=TZ),
- datetime(1999, 9, 2, 9, 0, tzinfo=TZ),]
- self.assertEqual(list(rr), exp)
- def testStrWithTZIDCallableFailure(self):
- rrstr = ('DTSTART;TZID=America/New_York:19970902T090000\n' +
- 'RRULE:FREQ=YEARLY;COUNT=3')
- class TzInfoError(Exception):
- pass
- def tzinfos(tzstr):
- if tzstr == 'America/New_York':
- raise TzInfoError('Invalid!')
- return None
- with self.assertRaises(TzInfoError):
- rrulestr(rrstr, tzids=tzinfos)
- def testStrWithConflictingTZID(self):
- # RFC 5545 Section 3.3.5, FORM #2: DATE WITH UTC TIME
- # https://tools.ietf.org/html/rfc5545#section-3.3.5
- # The "TZID" property parameter MUST NOT be applied to DATE-TIME
- with self.assertRaises(ValueError):
- rrulestr("DTSTART;TZID=America/New_York:19970902T090000Z\n"+
- "RRULE:FREQ=YEARLY;COUNT=3\n")
- def testStrType(self):
- self.assertEqual(isinstance(rrulestr(
- "DTSTART:19970902T090000\n"
- "RRULE:FREQ=YEARLY;COUNT=3\n"
- ), rrule), True)
- def testStrForceSetType(self):
- self.assertEqual(isinstance(rrulestr(
- "DTSTART:19970902T090000\n"
- "RRULE:FREQ=YEARLY;COUNT=3\n"
- , forceset=True), rruleset), True)
- def testStrSetType(self):
- self.assertEqual(isinstance(rrulestr(
- "DTSTART:19970902T090000\n"
- "RRULE:FREQ=YEARLY;COUNT=2;BYDAY=TU\n"
- "RRULE:FREQ=YEARLY;COUNT=1;BYDAY=TH\n"
- ), rruleset), True)
- def testStrCase(self):
- self.assertEqual(list(rrulestr(
- "dtstart:19970902T090000\n"
- "rrule:freq=yearly;count=3\n"
- )),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1998, 9, 2, 9, 0),
- datetime(1999, 9, 2, 9, 0)])
- def testStrSpaces(self):
- self.assertEqual(list(rrulestr(
- " DTSTART:19970902T090000 "
- " RRULE:FREQ=YEARLY;COUNT=3 "
- )),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1998, 9, 2, 9, 0),
- datetime(1999, 9, 2, 9, 0)])
- def testStrSpacesAndLines(self):
- self.assertEqual(list(rrulestr(
- " DTSTART:19970902T090000 \n"
- " \n"
- " RRULE:FREQ=YEARLY;COUNT=3 \n"
- )),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1998, 9, 2, 9, 0),
- datetime(1999, 9, 2, 9, 0)])
- def testStrNoDTStart(self):
- self.assertEqual(list(rrulestr(
- "RRULE:FREQ=YEARLY;COUNT=3\n"
- , dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1998, 9, 2, 9, 0),
- datetime(1999, 9, 2, 9, 0)])
- def testStrValueOnly(self):
- self.assertEqual(list(rrulestr(
- "FREQ=YEARLY;COUNT=3\n"
- , dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1998, 9, 2, 9, 0),
- datetime(1999, 9, 2, 9, 0)])
- def testStrUnfold(self):
- self.assertEqual(list(rrulestr(
- "FREQ=YEA\n RLY;COUNT=3\n", unfold=True,
- dtstart=datetime(1997, 9, 2, 9, 0))),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1998, 9, 2, 9, 0),
- datetime(1999, 9, 2, 9, 0)])
- def testStrSet(self):
- self.assertEqual(list(rrulestr(
- "DTSTART:19970902T090000\n"
- "RRULE:FREQ=YEARLY;COUNT=2;BYDAY=TU\n"
- "RRULE:FREQ=YEARLY;COUNT=1;BYDAY=TH\n"
- )),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 9, 9, 0)])
- def testStrSetDate(self):
- self.assertEqual(list(rrulestr(
- "DTSTART:19970902T090000\n"
- "RRULE:FREQ=YEARLY;COUNT=1;BYDAY=TU\n"
- "RDATE:19970904T090000\n"
- "RDATE:19970909T090000\n"
- )),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 9, 9, 0)])
- def testStrSetExRule(self):
- self.assertEqual(list(rrulestr(
- "DTSTART:19970902T090000\n"
- "RRULE:FREQ=YEARLY;COUNT=6;BYDAY=TU,TH\n"
- "EXRULE:FREQ=YEARLY;COUNT=3;BYDAY=TH\n"
- )),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 9, 9, 0),
- datetime(1997, 9, 16, 9, 0)])
- def testStrSetExDate(self):
- self.assertEqual(list(rrulestr(
- "DTSTART:19970902T090000\n"
- "RRULE:FREQ=YEARLY;COUNT=6;BYDAY=TU,TH\n"
- "EXDATE:19970904T090000\n"
- "EXDATE:19970911T090000\n"
- "EXDATE:19970918T090000\n"
- )),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 9, 9, 0),
- datetime(1997, 9, 16, 9, 0)])
- def testStrSetExDateMultiple(self):
- rrstr = ("DTSTART:19970902T090000\n"
- "RRULE:FREQ=YEARLY;COUNT=6;BYDAY=TU,TH\n"
- "EXDATE:19970904T090000,19970911T090000,19970918T090000\n")
- rr = rrulestr(rrstr)
- assert list(rr) == [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 9, 9, 0),
- datetime(1997, 9, 16, 9, 0)]
- def testStrSetExDateWithTZID(self):
- BXL = tz.gettz('Europe/Brussels')
- rr = rrulestr("DTSTART;TZID=Europe/Brussels:19970902T090000\n"
- "RRULE:FREQ=YEARLY;COUNT=6;BYDAY=TU,TH\n"
- "EXDATE;TZID=Europe/Brussels:19970904T090000\n"
- "EXDATE;TZID=Europe/Brussels:19970911T090000\n"
- "EXDATE;TZID=Europe/Brussels:19970918T090000\n")
- assert list(rr) == [datetime(1997, 9, 2, 9, 0, tzinfo=BXL),
- datetime(1997, 9, 9, 9, 0, tzinfo=BXL),
- datetime(1997, 9, 16, 9, 0, tzinfo=BXL)]
- def testStrSetExDateValueDateTimeNoTZID(self):
- rrstr = '\n'.join([
- "DTSTART:19970902T090000",
- "RRULE:FREQ=YEARLY;COUNT=4;BYDAY=TU,TH",
- "EXDATE;VALUE=DATE-TIME:19970902T090000",
- "EXDATE;VALUE=DATE-TIME:19970909T090000",
- ])
- rr = rrulestr(rrstr)
- assert list(rr) == [datetime(1997, 9, 4, 9), datetime(1997, 9, 11, 9)]
- def testStrSetExDateValueMixDateTimeNoTZID(self):
- rrstr = '\n'.join([
- "DTSTART:19970902T090000",
- "RRULE:FREQ=YEARLY;COUNT=4;BYDAY=TU,TH",
- "EXDATE;VALUE=DATE-TIME:19970902T090000",
- "EXDATE:19970909T090000",
- ])
- rr = rrulestr(rrstr)
- assert list(rr) == [datetime(1997, 9, 4, 9), datetime(1997, 9, 11, 9)]
- def testStrSetExDateValueDateTimeWithTZID(self):
- BXL = tz.gettz('Europe/Brussels')
- rrstr = '\n'.join([
- "DTSTART;VALUE=DATE-TIME;TZID=Europe/Brussels:19970902T090000",
- "RRULE:FREQ=YEARLY;COUNT=4;BYDAY=TU,TH",
- "EXDATE;VALUE=DATE-TIME;TZID=Europe/Brussels:19970902T090000",
- "EXDATE;VALUE=DATE-TIME;TZID=Europe/Brussels:19970909T090000",
- ])
- rr = rrulestr(rrstr)
- assert list(rr) == [datetime(1997, 9, 4, 9, tzinfo=BXL),
- datetime(1997, 9, 11, 9, tzinfo=BXL)]
- def testStrSetExDateValueDate(self):
- rrstr = '\n'.join([
- "DTSTART;VALUE=DATE:19970902",
- "RRULE:FREQ=YEARLY;COUNT=4;BYDAY=TU,TH",
- "EXDATE;VALUE=DATE:19970902",
- "EXDATE;VALUE=DATE:19970909",
- ])
- rr = rrulestr(rrstr)
- assert list(rr) == [datetime(1997, 9, 4), datetime(1997, 9, 11)]
- def testStrSetDateAndExDate(self):
- self.assertEqual(list(rrulestr(
- "DTSTART:19970902T090000\n"
- "RDATE:19970902T090000\n"
- "RDATE:19970904T090000\n"
- "RDATE:19970909T090000\n"
- "RDATE:19970911T090000\n"
- "RDATE:19970916T090000\n"
- "RDATE:19970918T090000\n"
- "EXDATE:19970904T090000\n"
- "EXDATE:19970911T090000\n"
- "EXDATE:19970918T090000\n"
- )),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 9, 9, 0),
- datetime(1997, 9, 16, 9, 0)])
- def testStrSetDateAndExRule(self):
- self.assertEqual(list(rrulestr(
- "DTSTART:19970902T090000\n"
- "RDATE:19970902T090000\n"
- "RDATE:19970904T090000\n"
- "RDATE:19970909T090000\n"
- "RDATE:19970911T090000\n"
- "RDATE:19970916T090000\n"
- "RDATE:19970918T090000\n"
- "EXRULE:FREQ=YEARLY;COUNT=3;BYDAY=TH\n"
- )),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 9, 9, 0),
- datetime(1997, 9, 16, 9, 0)])
- def testStrKeywords(self):
- self.assertEqual(list(rrulestr(
- "DTSTART:19970902T090000\n"
- "RRULE:FREQ=YEARLY;COUNT=3;INTERVAL=3;"
- "BYMONTH=3;BYWEEKDAY=TH;BYMONTHDAY=3;"
- "BYHOUR=3;BYMINUTE=3;BYSECOND=3\n"
- )),
- [datetime(2033, 3, 3, 3, 3, 3),
- datetime(2039, 3, 3, 3, 3, 3),
- datetime(2072, 3, 3, 3, 3, 3)])
- def testStrNWeekDay(self):
- self.assertEqual(list(rrulestr(
- "DTSTART:19970902T090000\n"
- "RRULE:FREQ=YEARLY;COUNT=3;BYDAY=1TU,-1TH\n"
- )),
- [datetime(1997, 12, 25, 9, 0),
- datetime(1998, 1, 6, 9, 0),
- datetime(1998, 12, 31, 9, 0)])
- def testStrUntil(self):
- self.assertEqual(list(rrulestr(
- "DTSTART:19970902T090000\n"
- "RRULE:FREQ=YEARLY;"
- "UNTIL=19990101T000000;BYDAY=1TU,-1TH\n"
- )),
- [datetime(1997, 12, 25, 9, 0),
- datetime(1998, 1, 6, 9, 0),
- datetime(1998, 12, 31, 9, 0)])
- def testStrValueDatetime(self):
- rr = rrulestr("DTSTART;VALUE=DATE-TIME:19970902T090000\n"
- "RRULE:FREQ=YEARLY;COUNT=2")
- self.assertEqual(list(rr), [datetime(1997, 9, 2, 9, 0, 0),
- datetime(1998, 9, 2, 9, 0, 0)])
- def testStrValueDate(self):
- rr = rrulestr("DTSTART;VALUE=DATE:19970902\n"
- "RRULE:FREQ=YEARLY;COUNT=2")
- self.assertEqual(list(rr), [datetime(1997, 9, 2, 0, 0, 0),
- datetime(1998, 9, 2, 0, 0, 0)])
- def testStrMultipleDTStartComma(self):
- with pytest.raises(ValueError):
- rr = rrulestr("DTSTART:19970101T000000,19970202T000000\n"
- "RRULE:FREQ=YEARLY;COUNT=1")
- def testStrInvalidUntil(self):
- with self.assertRaises(ValueError):
- list(rrulestr("DTSTART:19970902T090000\n"
- "RRULE:FREQ=YEARLY;"
- "UNTIL=TheCowsComeHome;BYDAY=1TU,-1TH\n"))
- def testStrUntilMustBeUTC(self):
- with self.assertRaises(ValueError):
- list(rrulestr("DTSTART;TZID=America/New_York:19970902T090000\n"
- "RRULE:FREQ=YEARLY;"
- "UNTIL=19990101T000000;BYDAY=1TU,-1TH\n"))
- def testStrUntilWithTZ(self):
- NYC = tz.gettz('America/New_York')
- rr = list(rrulestr("DTSTART;TZID=America/New_York:19970101T000000\n"
- "RRULE:FREQ=YEARLY;"
- "UNTIL=19990101T000000Z\n"))
- self.assertEqual(list(rr), [datetime(1997, 1, 1, 0, 0, 0, tzinfo=NYC),
- datetime(1998, 1, 1, 0, 0, 0, tzinfo=NYC)])
- def testStrEmptyByDay(self):
- with self.assertRaises(ValueError):
- list(rrulestr("DTSTART:19970902T090000\n"
- "FREQ=WEEKLY;"
- "BYDAY=;" # This part is invalid
- "WKST=SU"))
- def testStrInvalidByDay(self):
- with self.assertRaises(ValueError):
- list(rrulestr("DTSTART:19970902T090000\n"
- "FREQ=WEEKLY;"
- "BYDAY=-1OK;" # This part is invalid
- "WKST=SU"))
- def testBadBySetPos(self):
- self.assertRaises(ValueError,
- rrule, MONTHLY,
- count=1,
- bysetpos=0,
- dtstart=datetime(1997, 9, 2, 9, 0))
- def testBadBySetPosMany(self):
- self.assertRaises(ValueError,
- rrule, MONTHLY,
- count=1,
- bysetpos=(-1, 0, 1),
- dtstart=datetime(1997, 9, 2, 9, 0))
- # Tests to ensure that str(rrule) works
- def testToStrYearly(self):
- rule = rrule(YEARLY, count=3, dtstart=datetime(1997, 9, 2, 9, 0))
- self._rrulestr_reverse_test(rule)
- def testToStrYearlyInterval(self):
- rule = rrule(YEARLY, count=3, interval=2,
- dtstart=datetime(1997, 9, 2, 9, 0))
- self._rrulestr_reverse_test(rule)
- def testToStrYearlyByMonth(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- bymonth=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByMonthDay(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- bymonthday=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByMonthAndMonthDay(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(5, 7),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByWeekDay(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByNWeekDay(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByNWeekDayLarge(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byweekday=(TU(3), TH(-3)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByMonthAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByMonthAndNWeekDay(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByMonthAndNWeekDayLarge(self):
- # This is interesting because the TH(-3) ends up before
- # the TU(3).
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(3), TH(-3)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByMonthDayAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByMonthAndMonthDayAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByYearDay(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=4,
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByYearDayNeg(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=4,
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByMonthAndYearDay(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByMonthAndYearDayNeg(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByWeekNo(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byweekno=20,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByWeekNoAndWeekDay(self):
- # That's a nice one. The first days of week number one
- # may be in the last year.
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byweekno=1,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByWeekNoAndWeekDayLarge(self):
- # Another nice test. The last days of week number 52/53
- # may be in the next year.
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byweekno=52,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByWeekNoAndWeekDayLast(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byweekno=-1,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByEaster(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byeaster=0,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByEasterPos(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byeaster=1,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByEasterNeg(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byeaster=-1,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByWeekNoAndWeekDay53(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byweekno=53,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByHour(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byhour=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByMinute(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyBySecond(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByHourAndMinute(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByHourAndSecond(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byhour=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByMinuteAndSecond(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyByHourAndMinuteAndSecond(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrYearlyBySetPos(self):
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=3,
- bymonthday=15,
- byhour=(6, 18),
- bysetpos=(3, -3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthly(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyInterval(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- interval=2,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyIntervalLarge(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- interval=18,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByMonth(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- bymonth=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByMonthDay(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- bymonthday=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByMonthAndMonthDay(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(5, 7),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByWeekDay(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- # Third Monday of the month
- self.assertEqual(rrule(MONTHLY,
- byweekday=(MO(+3)),
- dtstart=datetime(1997, 9, 1)).between(datetime(1997,
- 9,
- 1),
- datetime(1997,
- 12,
- 1)),
- [datetime(1997, 9, 15, 0, 0),
- datetime(1997, 10, 20, 0, 0),
- datetime(1997, 11, 17, 0, 0)])
- def testToStrMonthlyByNWeekDay(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByNWeekDayLarge(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byweekday=(TU(3), TH(-3)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByMonthAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByMonthAndNWeekDay(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByMonthAndNWeekDayLarge(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(3), TH(-3)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByMonthDayAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByMonthAndMonthDayAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByYearDay(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=4,
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByYearDayNeg(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=4,
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByMonthAndYearDay(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByMonthAndYearDayNeg(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByWeekNo(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byweekno=20,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByWeekNoAndWeekDay(self):
- # That's a nice one. The first days of week number one
- # may be in the last year.
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byweekno=1,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByWeekNoAndWeekDayLarge(self):
- # Another nice test. The last days of week number 52/53
- # may be in the next year.
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byweekno=52,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByWeekNoAndWeekDayLast(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byweekno=-1,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByWeekNoAndWeekDay53(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byweekno=53,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByEaster(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byeaster=0,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByEasterPos(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byeaster=1,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByEasterNeg(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byeaster=-1,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByHour(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byhour=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByMinute(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyBySecond(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByHourAndMinute(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByHourAndSecond(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byhour=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByMinuteAndSecond(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyByHourAndMinuteAndSecond(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMonthlyBySetPos(self):
- self._rrulestr_reverse_test(rrule(MONTHLY,
- count=3,
- bymonthday=(13, 17),
- byhour=(6, 18),
- bysetpos=(3, -3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeekly(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyInterval(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- interval=2,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyIntervalLarge(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- interval=20,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByMonth(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- bymonth=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByMonthDay(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- bymonthday=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByMonthAndMonthDay(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(5, 7),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByWeekDay(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByNWeekDay(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByMonthAndWeekDay(self):
- # This test is interesting, because it crosses the year
- # boundary in a weekly period to find day '1' as a
- # valid recurrence.
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByMonthAndNWeekDay(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByMonthDayAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByMonthAndMonthDayAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByYearDay(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=4,
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByYearDayNeg(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=4,
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByMonthAndYearDay(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=4,
- bymonth=(1, 7),
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByMonthAndYearDayNeg(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=4,
- bymonth=(1, 7),
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByWeekNo(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byweekno=20,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByWeekNoAndWeekDay(self):
- # That's a nice one. The first days of week number one
- # may be in the last year.
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byweekno=1,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByWeekNoAndWeekDayLarge(self):
- # Another nice test. The last days of week number 52/53
- # may be in the next year.
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byweekno=52,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByWeekNoAndWeekDayLast(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byweekno=-1,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByWeekNoAndWeekDay53(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byweekno=53,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByEaster(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byeaster=0,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByEasterPos(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byeaster=1,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByEasterNeg(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byeaster=-1,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByHour(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byhour=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByMinute(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyBySecond(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByHourAndMinute(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByHourAndSecond(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byhour=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByMinuteAndSecond(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyByHourAndMinuteAndSecond(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrWeeklyBySetPos(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- byweekday=(TU, TH),
- byhour=(6, 18),
- bysetpos=(3, -3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDaily(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyInterval(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- interval=2,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyIntervalLarge(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- interval=92,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByMonth(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- bymonth=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByMonthDay(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- bymonthday=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByMonthAndMonthDay(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(5, 7),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByWeekDay(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByNWeekDay(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByMonthAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByMonthAndNWeekDay(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByMonthDayAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByMonthAndMonthDayAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByYearDay(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=4,
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByYearDayNeg(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=4,
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByMonthAndYearDay(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=4,
- bymonth=(1, 7),
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByMonthAndYearDayNeg(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=4,
- bymonth=(1, 7),
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByWeekNo(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byweekno=20,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByWeekNoAndWeekDay(self):
- # That's a nice one. The first days of week number one
- # may be in the last year.
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byweekno=1,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByWeekNoAndWeekDayLarge(self):
- # Another nice test. The last days of week number 52/53
- # may be in the next year.
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byweekno=52,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByWeekNoAndWeekDayLast(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byweekno=-1,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByWeekNoAndWeekDay53(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byweekno=53,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByEaster(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byeaster=0,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByEasterPos(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byeaster=1,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByEasterNeg(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byeaster=-1,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByHour(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byhour=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByMinute(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyBySecond(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByHourAndMinute(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByHourAndSecond(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byhour=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByMinuteAndSecond(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyByHourAndMinuteAndSecond(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrDailyBySetPos(self):
- self._rrulestr_reverse_test(rrule(DAILY,
- count=3,
- byhour=(6, 18),
- byminute=(15, 45),
- bysetpos=(3, -3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourly(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyInterval(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- interval=2,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyIntervalLarge(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- interval=769,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByMonth(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- bymonth=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByMonthDay(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- bymonthday=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByMonthAndMonthDay(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(5, 7),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByWeekDay(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByNWeekDay(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByMonthAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByMonthAndNWeekDay(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByMonthDayAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByMonthAndMonthDayAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByYearDay(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=4,
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByYearDayNeg(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=4,
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByMonthAndYearDay(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByMonthAndYearDayNeg(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByWeekNo(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byweekno=20,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByWeekNoAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byweekno=1,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByWeekNoAndWeekDayLarge(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byweekno=52,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByWeekNoAndWeekDayLast(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byweekno=-1,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByWeekNoAndWeekDay53(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byweekno=53,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByEaster(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byeaster=0,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByEasterPos(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byeaster=1,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByEasterNeg(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byeaster=-1,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByHour(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byhour=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByMinute(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyBySecond(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByHourAndMinute(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByHourAndSecond(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byhour=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByMinuteAndSecond(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyByHourAndMinuteAndSecond(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrHourlyBySetPos(self):
- self._rrulestr_reverse_test(rrule(HOURLY,
- count=3,
- byminute=(15, 45),
- bysecond=(15, 45),
- bysetpos=(3, -3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutely(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyInterval(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- interval=2,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyIntervalLarge(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- interval=1501,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByMonth(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- bymonth=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByMonthDay(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- bymonthday=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByMonthAndMonthDay(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(5, 7),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByWeekDay(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByNWeekDay(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByMonthAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByMonthAndNWeekDay(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByMonthDayAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByMonthAndMonthDayAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByYearDay(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=4,
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByYearDayNeg(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=4,
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByMonthAndYearDay(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=4,
- bymonth=(4, 7),
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByMonthAndYearDayNeg(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=4,
- bymonth=(4, 7),
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByWeekNo(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byweekno=20,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByWeekNoAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byweekno=1,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByWeekNoAndWeekDayLarge(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byweekno=52,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByWeekNoAndWeekDayLast(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byweekno=-1,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByWeekNoAndWeekDay53(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byweekno=53,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByEaster(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byeaster=0,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByEasterPos(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byeaster=1,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByEasterNeg(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byeaster=-1,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByHour(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byhour=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByMinute(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyBySecond(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByHourAndMinute(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByHourAndSecond(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byhour=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByMinuteAndSecond(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyByHourAndMinuteAndSecond(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrMinutelyBySetPos(self):
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=3,
- bysecond=(15, 30, 45),
- bysetpos=(3, -3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondly(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyInterval(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- interval=2,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyIntervalLarge(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- interval=90061,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByMonth(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- bymonth=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByMonthDay(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- bymonthday=(1, 3),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByMonthAndMonthDay(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(5, 7),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByWeekDay(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByNWeekDay(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByMonthAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByMonthAndNWeekDay(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- bymonth=(1, 3),
- byweekday=(TU(1), TH(-1)),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByMonthDayAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByMonthAndMonthDayAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- bymonth=(1, 3),
- bymonthday=(1, 3),
- byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByYearDay(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=4,
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByYearDayNeg(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=4,
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByMonthAndYearDay(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(1, 100, 200, 365),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByMonthAndYearDayNeg(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=4,
- bymonth=(4, 7),
- byyearday=(-365, -266, -166, -1),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByWeekNo(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byweekno=20,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByWeekNoAndWeekDay(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byweekno=1,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByWeekNoAndWeekDayLarge(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byweekno=52,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByWeekNoAndWeekDayLast(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byweekno=-1,
- byweekday=SU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByWeekNoAndWeekDay53(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byweekno=53,
- byweekday=MO,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByEaster(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byeaster=0,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByEasterPos(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byeaster=1,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByEasterNeg(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byeaster=-1,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByHour(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byhour=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByMinute(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyBySecond(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByHourAndMinute(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByHourAndSecond(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byhour=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByMinuteAndSecond(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByHourAndMinuteAndSecond(self):
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- byhour=(6, 18),
- byminute=(6, 18),
- bysecond=(6, 18),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrSecondlyByHourAndMinuteAndSecondBug(self):
- # This explores a bug found by Mathieu Bridon.
- self._rrulestr_reverse_test(rrule(SECONDLY,
- count=3,
- bysecond=(0,),
- byminute=(1,),
- dtstart=datetime(2010, 3, 22, 12, 1)))
- def testToStrWithWkSt(self):
- self._rrulestr_reverse_test(rrule(WEEKLY,
- count=3,
- wkst=SU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testToStrLongIntegers(self):
- if PY2: # There are no longs in python3
- self._rrulestr_reverse_test(rrule(MINUTELY,
- count=long(2),
- interval=long(2),
- bymonth=long(2),
- byweekday=long(3),
- byhour=long(6),
- byminute=long(6),
- bysecond=long(6),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- self._rrulestr_reverse_test(rrule(YEARLY,
- count=long(2),
- bymonthday=long(5),
- byweekno=long(2),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- def testReplaceIfSet(self):
- rr = rrule(YEARLY,
- count=1,
- bymonthday=5,
- dtstart=datetime(1997, 1, 1))
- newrr = rr.replace(bymonthday=6)
- self.assertEqual(list(rr), [datetime(1997, 1, 5)])
- self.assertEqual(list(newrr),
- [datetime(1997, 1, 6)])
- def testReplaceIfNotSet(self):
- rr = rrule(YEARLY,
- count=1,
- dtstart=datetime(1997, 1, 1))
- newrr = rr.replace(bymonthday=6)
- self.assertEqual(list(rr), [datetime(1997, 1, 1)])
- self.assertEqual(list(newrr),
- [datetime(1997, 1, 6)])
- @pytest.mark.rrule
- @freeze_time(datetime(2018, 3, 6, 5, 36, tzinfo=tz.UTC))
- def test_generated_aware_dtstart():
- dtstart_exp = datetime(2018, 3, 6, 5, 36, tzinfo=tz.UTC)
- UNTIL = datetime(2018, 3, 6, 8, 0, tzinfo=tz.UTC)
- rule_without_dtstart = rrule(freq=HOURLY, until=UNTIL)
- rule_with_dtstart = rrule(freq=HOURLY, dtstart=dtstart_exp, until=UNTIL)
- assert list(rule_without_dtstart) == list(rule_with_dtstart)
- @pytest.mark.rrule
- @pytest.mark.rrulestr
- @pytest.mark.xfail(reason="rrulestr loses time zone, gh issue #637")
- @freeze_time(datetime(2018, 3, 6, 5, 36, tzinfo=tz.UTC))
- def test_generated_aware_dtstart_rrulestr():
- rrule_without_dtstart = rrule(freq=HOURLY,
- until=datetime(2018, 3, 6, 8, 0,
- tzinfo=tz.UTC))
- rrule_r = rrulestr(str(rrule_without_dtstart))
- assert list(rrule_r) == list(rrule_without_dtstart)
- @pytest.mark.rruleset
- class RRuleSetTest(unittest.TestCase):
- def testSet(self):
- rrset = rruleset()
- rrset.rrule(rrule(YEARLY, count=2, byweekday=TU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- rrset.rrule(rrule(YEARLY, count=1, byweekday=TH,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- self.assertEqual(list(rrset),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 9, 9, 0)])
- def testSetDate(self):
- rrset = rruleset()
- rrset.rrule(rrule(YEARLY, count=1, byweekday=TU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- rrset.rdate(datetime(1997, 9, 4, 9))
- rrset.rdate(datetime(1997, 9, 9, 9))
- self.assertEqual(list(rrset),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 9, 9, 0)])
- def testSetExRule(self):
- rrset = rruleset()
- rrset.rrule(rrule(YEARLY, count=6, byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- rrset.exrule(rrule(YEARLY, count=3, byweekday=TH,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- self.assertEqual(list(rrset),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 9, 9, 0),
- datetime(1997, 9, 16, 9, 0)])
- def testSetExDate(self):
- rrset = rruleset()
- rrset.rrule(rrule(YEARLY, count=6, byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- rrset.exdate(datetime(1997, 9, 4, 9))
- rrset.exdate(datetime(1997, 9, 11, 9))
- rrset.exdate(datetime(1997, 9, 18, 9))
- self.assertEqual(list(rrset),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 9, 9, 0),
- datetime(1997, 9, 16, 9, 0)])
- def testSetExDateRevOrder(self):
- rrset = rruleset()
- rrset.rrule(rrule(MONTHLY, count=5, bymonthday=10,
- dtstart=datetime(2004, 1, 1, 9, 0)))
- rrset.exdate(datetime(2004, 4, 10, 9, 0))
- rrset.exdate(datetime(2004, 2, 10, 9, 0))
- self.assertEqual(list(rrset),
- [datetime(2004, 1, 10, 9, 0),
- datetime(2004, 3, 10, 9, 0),
- datetime(2004, 5, 10, 9, 0)])
- def testSetDateAndExDate(self):
- rrset = rruleset()
- rrset.rdate(datetime(1997, 9, 2, 9))
- rrset.rdate(datetime(1997, 9, 4, 9))
- rrset.rdate(datetime(1997, 9, 9, 9))
- rrset.rdate(datetime(1997, 9, 11, 9))
- rrset.rdate(datetime(1997, 9, 16, 9))
- rrset.rdate(datetime(1997, 9, 18, 9))
- rrset.exdate(datetime(1997, 9, 4, 9))
- rrset.exdate(datetime(1997, 9, 11, 9))
- rrset.exdate(datetime(1997, 9, 18, 9))
- self.assertEqual(list(rrset),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 9, 9, 0),
- datetime(1997, 9, 16, 9, 0)])
- def testSetDateAndExRule(self):
- rrset = rruleset()
- rrset.rdate(datetime(1997, 9, 2, 9))
- rrset.rdate(datetime(1997, 9, 4, 9))
- rrset.rdate(datetime(1997, 9, 9, 9))
- rrset.rdate(datetime(1997, 9, 11, 9))
- rrset.rdate(datetime(1997, 9, 16, 9))
- rrset.rdate(datetime(1997, 9, 18, 9))
- rrset.exrule(rrule(YEARLY, count=3, byweekday=TH,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- self.assertEqual(list(rrset),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 9, 9, 0),
- datetime(1997, 9, 16, 9, 0)])
- def testSetCount(self):
- rrset = rruleset()
- rrset.rrule(rrule(YEARLY, count=6, byweekday=(TU, TH),
- dtstart=datetime(1997, 9, 2, 9, 0)))
- rrset.exrule(rrule(YEARLY, count=3, byweekday=TH,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- self.assertEqual(rrset.count(), 3)
- def testSetCachePre(self):
- rrset = rruleset()
- rrset.rrule(rrule(YEARLY, count=2, byweekday=TU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- rrset.rrule(rrule(YEARLY, count=1, byweekday=TH,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- self.assertEqual(list(rrset),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 9, 9, 0)])
- def testSetCachePost(self):
- rrset = rruleset(cache=True)
- rrset.rrule(rrule(YEARLY, count=2, byweekday=TU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- rrset.rrule(rrule(YEARLY, count=1, byweekday=TH,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- for x in rrset: pass
- self.assertEqual(list(rrset),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 9, 9, 0)])
- def testSetCachePostInternal(self):
- rrset = rruleset(cache=True)
- rrset.rrule(rrule(YEARLY, count=2, byweekday=TU,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- rrset.rrule(rrule(YEARLY, count=1, byweekday=TH,
- dtstart=datetime(1997, 9, 2, 9, 0)))
- for x in rrset: pass
- self.assertEqual(list(rrset._cache),
- [datetime(1997, 9, 2, 9, 0),
- datetime(1997, 9, 4, 9, 0),
- datetime(1997, 9, 9, 9, 0)])
- def testSetRRuleCount(self):
- # Test that the count is updated when an rrule is added
- rrset = rruleset(cache=False)
- for cache in (True, False):
- rrset = rruleset(cache=cache)
- rrset.rrule(rrule(YEARLY, count=2, byweekday=TH,
- dtstart=datetime(1983, 4, 1)))
- rrset.rrule(rrule(WEEKLY, count=4, byweekday=FR,
- dtstart=datetime(1991, 6, 3)))
- # Check the length twice - first one sets a cache, second reads it
- self.assertEqual(rrset.count(), 6)
- self.assertEqual(rrset.count(), 6)
- # This should invalidate the cache and force an update
- rrset.rrule(rrule(MONTHLY, count=3, dtstart=datetime(1994, 1, 3)))
- self.assertEqual(rrset.count(), 9)
- self.assertEqual(rrset.count(), 9)
- def testSetRDateCount(self):
- # Test that the count is updated when an rdate is added
- rrset = rruleset(cache=False)
- for cache in (True, False):
- rrset = rruleset(cache=cache)
- rrset.rrule(rrule(YEARLY, count=2, byweekday=TH,
- dtstart=datetime(1983, 4, 1)))
- rrset.rrule(rrule(WEEKLY, count=4, byweekday=FR,
- dtstart=datetime(1991, 6, 3)))
- # Check the length twice - first one sets a cache, second reads it
- self.assertEqual(rrset.count(), 6)
- self.assertEqual(rrset.count(), 6)
- # This should invalidate the cache and force an update
- rrset.rdate(datetime(1993, 2, 14))
- self.assertEqual(rrset.count(), 7)
- self.assertEqual(rrset.count(), 7)
- def testSetExRuleCount(self):
- # Test that the count is updated when an exrule is added
- rrset = rruleset(cache=False)
- for cache in (True, False):
- rrset = rruleset(cache=cache)
- rrset.rrule(rrule(YEARLY, count=2, byweekday=TH,
- dtstart=datetime(1983, 4, 1)))
- rrset.rrule(rrule(WEEKLY, count=4, byweekday=FR,
- dtstart=datetime(1991, 6, 3)))
- # Check the length twice - first one sets a cache, second reads it
- self.assertEqual(rrset.count(), 6)
- self.assertEqual(rrset.count(), 6)
- # This should invalidate the cache and force an update
- rrset.exrule(rrule(WEEKLY, count=2, interval=2,
- dtstart=datetime(1991, 6, 14)))
- self.assertEqual(rrset.count(), 4)
- self.assertEqual(rrset.count(), 4)
- def testSetExDateCount(self):
- # Test that the count is updated when an rdate is added
- for cache in (True, False):
- rrset = rruleset(cache=cache)
- rrset.rrule(rrule(YEARLY, count=2, byweekday=TH,
- dtstart=datetime(1983, 4, 1)))
- rrset.rrule(rrule(WEEKLY, count=4, byweekday=FR,
- dtstart=datetime(1991, 6, 3)))
- # Check the length twice - first one sets a cache, second reads it
- self.assertEqual(rrset.count(), 6)
- self.assertEqual(rrset.count(), 6)
- # This should invalidate the cache and force an update
- rrset.exdate(datetime(1991, 6, 28))
- self.assertEqual(rrset.count(), 5)
- self.assertEqual(rrset.count(), 5)
- class WeekdayTest(unittest.TestCase):
- def testInvalidNthWeekday(self):
- with self.assertRaises(ValueError):
- FR(0)
- def testWeekdayCallable(self):
- # Calling a weekday instance generates a new weekday instance with the
- # value of n changed.
- from dateutil.rrule import weekday
- self.assertEqual(MO(1), weekday(0, 1))
- # Calling a weekday instance with the identical n returns the original
- # object
- FR_3 = weekday(4, 3)
- self.assertIs(FR_3(3), FR_3)
- def testWeekdayEquality(self):
- # Two weekday objects are not equal if they have different values for n
- self.assertNotEqual(TH, TH(-1))
- self.assertNotEqual(SA(3), SA(2))
- def testWeekdayEqualitySubclass(self):
- # Two weekday objects equal if their "weekday" and "n" attributes are
- # available and the same
- class BasicWeekday(object):
- def __init__(self, weekday):
- self.weekday = weekday
- class BasicNWeekday(BasicWeekday):
- def __init__(self, weekday, n=None):
- super(BasicNWeekday, self).__init__(weekday)
- self.n = n
- MO_Basic = BasicWeekday(0)
- self.assertNotEqual(MO, MO_Basic)
- self.assertNotEqual(MO(1), MO_Basic)
- TU_BasicN = BasicNWeekday(1)
- self.assertEqual(TU, TU_BasicN)
- self.assertNotEqual(TU(3), TU_BasicN)
- WE_Basic3 = BasicNWeekday(2, 3)
- self.assertEqual(WE(3), WE_Basic3)
- self.assertNotEqual(WE(2), WE_Basic3)
- def testWeekdayReprNoN(self):
- no_n_reprs = ('MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU')
- no_n_wdays = (MO, TU, WE, TH, FR, SA, SU)
- for repstr, wday in zip(no_n_reprs, no_n_wdays):
- self.assertEqual(repr(wday), repstr)
- def testWeekdayReprWithN(self):
- with_n_reprs = ('WE(+1)', 'TH(-2)', 'SU(+3)')
- with_n_wdays = (WE(1), TH(-2), SU(+3))
- for repstr, wday in zip(with_n_reprs, with_n_wdays):
- self.assertEqual(repr(wday), repstr)
|