Best Python code snippet using freezegun
test_serialize.py
Source:test_serialize.py
1# Copyright (C) 2016 Okami, okami@fuzetsu.info2# This program is free software; you can redistribute it and/or3# modify it under the terms of the GNU General Public License4# as published by the Free Software Foundation; either version 35# of the License, or (at your option) any later version.6# This program is distributed in the hope that it will be useful,7# but WITHOUT ANY WARRANTY; without even the implied warranty of8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9# GNU General Public License for more details.10# You should have received a copy of the GNU General Public License11# along with this program; if not, write to the Free Software12# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.13from django.test import TestCase14# from radicale import ical15# from ..storage.django import ICAL_TYPES16class SerializationTestCase(TestCase):17 DATA_CASES = ((18 '''BEGIN:VCALENDAR19CALSCALE:GREGORIAN20PRODID:-//Ximian//NONSGML Evolution Calendar//EN21VERSION:2.022BEGIN:VTIMEZONE23TZID:/freeassociation.sourceforge.net/Europe/Moscow24X-LIC-LOCATION:Europe/Moscow25BEGIN:STANDARD26TZNAME:MSK27DTSTART:19300621T00000028TZOFFSETFROM:+040029TZOFFSETTO:+030030END:STANDARD31BEGIN:DAYLIGHT32TZNAME:MSD33DTSTART:19810401T00000034TZOFFSETFROM:+030035TZOFFSETTO:+040036END:DAYLIGHT37BEGIN:STANDARD38TZNAME:MSK39DTSTART:19811001T00000040TZOFFSETFROM:+040041TZOFFSETTO:+030042END:STANDARD43BEGIN:DAYLIGHT44TZNAME:MSD45DTSTART:19820401T00000046TZOFFSETFROM:+030047TZOFFSETTO:+040048END:DAYLIGHT49BEGIN:STANDARD50TZNAME:MSK51DTSTART:19821001T00000052TZOFFSETFROM:+040053TZOFFSETTO:+030054END:STANDARD55BEGIN:DAYLIGHT56TZNAME:MSD57DTSTART:19830401T00000058TZOFFSETFROM:+030059TZOFFSETTO:+040060END:DAYLIGHT61BEGIN:STANDARD62TZNAME:MSK63DTSTART:19831001T00000064TZOFFSETFROM:+040065TZOFFSETTO:+030066END:STANDARD67BEGIN:DAYLIGHT68TZNAME:MSD69DTSTART:19840401T00000070TZOFFSETFROM:+030071TZOFFSETTO:+040072END:DAYLIGHT73BEGIN:STANDARD74TZNAME:MSK75DTSTART:19840930T03000076TZOFFSETFROM:+040077TZOFFSETTO:+030078END:STANDARD79BEGIN:DAYLIGHT80TZNAME:MSD81DTSTART:19850331T02000082TZOFFSETFROM:+030083TZOFFSETTO:+040084END:DAYLIGHT85BEGIN:STANDARD86TZNAME:MSK87DTSTART:19850929T03000088TZOFFSETFROM:+040089TZOFFSETTO:+030090END:STANDARD91BEGIN:DAYLIGHT92TZNAME:MSD93DTSTART:19860330T02000094TZOFFSETFROM:+030095TZOFFSETTO:+040096END:DAYLIGHT97BEGIN:STANDARD98TZNAME:MSK99DTSTART:19860928T030000100TZOFFSETFROM:+0400101TZOFFSETTO:+0300102END:STANDARD103BEGIN:DAYLIGHT104TZNAME:MSD105DTSTART:19870329T020000106TZOFFSETFROM:+0300107TZOFFSETTO:+0400108END:DAYLIGHT109BEGIN:STANDARD110TZNAME:MSK111DTSTART:19870927T030000112TZOFFSETFROM:+0400113TZOFFSETTO:+0300114END:STANDARD115BEGIN:DAYLIGHT116TZNAME:MSD117DTSTART:19880327T020000118TZOFFSETFROM:+0300119TZOFFSETTO:+0400120END:DAYLIGHT121BEGIN:STANDARD122TZNAME:MSK123DTSTART:19880925T030000124TZOFFSETFROM:+0400125TZOFFSETTO:+0300126END:STANDARD127BEGIN:DAYLIGHT128TZNAME:MSD129DTSTART:19890326T020000130TZOFFSETFROM:+0300131TZOFFSETTO:+0400132END:DAYLIGHT133BEGIN:STANDARD134TZNAME:MSK135DTSTART:19890924T030000136TZOFFSETFROM:+0400137TZOFFSETTO:+0300138END:STANDARD139BEGIN:DAYLIGHT140TZNAME:MSD141DTSTART:19900325T020000142TZOFFSETFROM:+0300143TZOFFSETTO:+0400144END:DAYLIGHT145BEGIN:STANDARD146TZNAME:MSK147DTSTART:19900930T030000148TZOFFSETFROM:+0300149TZOFFSETTO:+0300150END:STANDARD151BEGIN:DAYLIGHT152TZNAME:EEST153DTSTART:19910331T020000154TZOFFSETFROM:+0200155TZOFFSETTO:+0300156END:DAYLIGHT157BEGIN:STANDARD158TZNAME:EET159DTSTART:19910929T030000160TZOFFSETFROM:+0300161TZOFFSETTO:+0200162END:STANDARD163BEGIN:STANDARD164TZNAME:MSK165DTSTART:19920119T020000166TZOFFSETFROM:+0400167TZOFFSETTO:+0300168END:STANDARD169BEGIN:DAYLIGHT170TZNAME:MSD171DTSTART:19920329T020000172TZOFFSETFROM:+0300173TZOFFSETTO:+0400174END:DAYLIGHT175BEGIN:STANDARD176TZNAME:MSK177DTSTART:19920927T030000178TZOFFSETFROM:+0400179TZOFFSETTO:+0300180END:STANDARD181BEGIN:DAYLIGHT182TZNAME:MSD183DTSTART:19930328T020000184TZOFFSETFROM:+0300185TZOFFSETTO:+0400186END:DAYLIGHT187BEGIN:STANDARD188TZNAME:MSK189DTSTART:19930926T030000190TZOFFSETFROM:+0400191TZOFFSETTO:+0300192END:STANDARD193BEGIN:DAYLIGHT194TZNAME:MSD195DTSTART:19940327T020000196TZOFFSETFROM:+0300197TZOFFSETTO:+0400198END:DAYLIGHT199BEGIN:STANDARD200TZNAME:MSK201DTSTART:19940925T030000202TZOFFSETFROM:+0400203TZOFFSETTO:+0300204END:STANDARD205BEGIN:DAYLIGHT206TZNAME:MSD207DTSTART:19950326T020000208TZOFFSETFROM:+0300209TZOFFSETTO:+0400210END:DAYLIGHT211BEGIN:STANDARD212TZNAME:MSK213DTSTART:19950924T030000214TZOFFSETFROM:+0400215TZOFFSETTO:+0300216END:STANDARD217BEGIN:DAYLIGHT218TZNAME:MSD219DTSTART:19960331T020000220TZOFFSETFROM:+0300221TZOFFSETTO:+0400222END:DAYLIGHT223BEGIN:STANDARD224TZNAME:MSK225DTSTART:19961027T030000226TZOFFSETFROM:+0400227TZOFFSETTO:+0300228END:STANDARD229BEGIN:DAYLIGHT230TZNAME:MSD231DTSTART:19970330T020000232TZOFFSETFROM:+0300233TZOFFSETTO:+0400234END:DAYLIGHT235BEGIN:STANDARD236TZNAME:MSK237DTSTART:19971026T030000238TZOFFSETFROM:+0400239TZOFFSETTO:+0300240END:STANDARD241BEGIN:DAYLIGHT242TZNAME:MSD243DTSTART:19980329T020000244TZOFFSETFROM:+0300245TZOFFSETTO:+0400246END:DAYLIGHT247BEGIN:STANDARD248TZNAME:MSK249DTSTART:19981025T030000250TZOFFSETFROM:+0400251TZOFFSETTO:+0300252END:STANDARD253BEGIN:DAYLIGHT254TZNAME:MSD255DTSTART:19990328T020000256TZOFFSETFROM:+0300257TZOFFSETTO:+0400258END:DAYLIGHT259BEGIN:STANDARD260TZNAME:MSK261DTSTART:19991031T030000262TZOFFSETFROM:+0400263TZOFFSETTO:+0300264END:STANDARD265BEGIN:DAYLIGHT266TZNAME:MSD267DTSTART:20000326T020000268TZOFFSETFROM:+0300269TZOFFSETTO:+0400270END:DAYLIGHT271BEGIN:STANDARD272TZNAME:MSK273DTSTART:20001029T030000274TZOFFSETFROM:+0400275TZOFFSETTO:+0300276END:STANDARD277BEGIN:DAYLIGHT278TZNAME:MSD279DTSTART:20010325T020000280TZOFFSETFROM:+0300281TZOFFSETTO:+0400282END:DAYLIGHT283BEGIN:STANDARD284TZNAME:MSK285DTSTART:20011028T030000286TZOFFSETFROM:+0400287TZOFFSETTO:+0300288END:STANDARD289BEGIN:DAYLIGHT290TZNAME:MSD291DTSTART:20020331T020000292TZOFFSETFROM:+0300293TZOFFSETTO:+0400294END:DAYLIGHT295BEGIN:STANDARD296TZNAME:MSK297DTSTART:20021027T030000298TZOFFSETFROM:+0400299TZOFFSETTO:+0300300END:STANDARD301BEGIN:DAYLIGHT302TZNAME:MSD303DTSTART:20030330T020000304TZOFFSETFROM:+0300305TZOFFSETTO:+0400306END:DAYLIGHT307BEGIN:STANDARD308TZNAME:MSK309DTSTART:20031026T030000310TZOFFSETFROM:+0400311TZOFFSETTO:+0300312END:STANDARD313BEGIN:DAYLIGHT314TZNAME:MSD315DTSTART:20040328T020000316TZOFFSETFROM:+0300317TZOFFSETTO:+0400318END:DAYLIGHT319BEGIN:STANDARD320TZNAME:MSK321DTSTART:20041031T030000322TZOFFSETFROM:+0400323TZOFFSETTO:+0300324END:STANDARD325BEGIN:DAYLIGHT326TZNAME:MSD327DTSTART:20050327T020000328TZOFFSETFROM:+0300329TZOFFSETTO:+0400330END:DAYLIGHT331BEGIN:STANDARD332TZNAME:MSK333DTSTART:20051030T030000334TZOFFSETFROM:+0400335TZOFFSETTO:+0300336END:STANDARD337BEGIN:DAYLIGHT338TZNAME:MSD339DTSTART:20060326T020000340TZOFFSETFROM:+0300341TZOFFSETTO:+0400342END:DAYLIGHT343BEGIN:STANDARD344TZNAME:MSK345DTSTART:20061029T030000346TZOFFSETFROM:+0400347TZOFFSETTO:+0300348END:STANDARD349BEGIN:DAYLIGHT350TZNAME:MSD351DTSTART:20070325T020000352TZOFFSETFROM:+0300353TZOFFSETTO:+0400354END:DAYLIGHT355BEGIN:STANDARD356TZNAME:MSK357DTSTART:20071028T030000358TZOFFSETFROM:+0400359TZOFFSETTO:+0300360END:STANDARD361BEGIN:DAYLIGHT362TZNAME:MSD363DTSTART:20080330T020000364TZOFFSETFROM:+0300365TZOFFSETTO:+0400366END:DAYLIGHT367BEGIN:STANDARD368TZNAME:MSK369DTSTART:20081026T030000370TZOFFSETFROM:+0400371TZOFFSETTO:+0300372END:STANDARD373BEGIN:DAYLIGHT374TZNAME:MSD375DTSTART:20090329T020000376TZOFFSETFROM:+0300377TZOFFSETTO:+0400378END:DAYLIGHT379BEGIN:STANDARD380TZNAME:MSK381DTSTART:20091025T030000382TZOFFSETFROM:+0400383TZOFFSETTO:+0300384END:STANDARD385BEGIN:DAYLIGHT386TZNAME:MSD387DTSTART:20100328T020000388TZOFFSETFROM:+0300389TZOFFSETTO:+0400390END:DAYLIGHT391BEGIN:STANDARD392TZNAME:MSK393DTSTART:20101031T030000394TZOFFSETFROM:+0400395TZOFFSETTO:+0300396END:STANDARD397BEGIN:STANDARD398TZNAME:MSK399DTSTART:20110327T020000400TZOFFSETFROM:+0300401TZOFFSETTO:+0400402END:STANDARD403BEGIN:STANDARD404TZNAME:MSK405DTSTART:20141026T020000406TZOFFSETFROM:+0400407TZOFFSETTO:+0300408END:STANDARD409END:VTIMEZONE410BEGIN:VEVENT411UID:20160729T101032Z-9313-1000-4291-10@localhost412DTSTAMP:20160729T063824Z413DTSTART;TZID=/freeassociation.sourceforge.net/Europe/Moscow:414 20160721T090000415DTEND;TZID=/freeassociation.sourceforge.net/Europe/Moscow:416 20160721T093000417SEQUENCE:2418SUMMARY:zzzzz419CLASS:PUBLIC420TRANSP:OPAQUE421CREATED:20160729T101116Z422LAST-MODIFIED:20160729T101116Z423END:VEVENT424END:VCALENDAR''',425 '''BEGIN:VCALENDAR426PRODID:-//Radicale//NONSGML Radicale Server//EN427VERSION:2.0428BEGIN:VTIMEZONE429TZID:/freeassociation.sourceforge.net/Europe/Moscow430X-LIC-LOCATION:Europe/Moscow431BEGIN:STANDARD432TZNAME:MSK433DTSTART:19300621T000000434TZOFFSETFROM:+0400435TZOFFSETTO:+0300436X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow437END:STANDARD438BEGIN:DAYLIGHT439TZNAME:MSD440DTSTART:19810401T000000441TZOFFSETFROM:+0300442TZOFFSETTO:+0400443X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow444END:DAYLIGHT445BEGIN:STANDARD446TZNAME:MSK447DTSTART:19811001T000000448TZOFFSETFROM:+0400449TZOFFSETTO:+0300450X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow451END:STANDARD452BEGIN:DAYLIGHT453TZNAME:MSD454DTSTART:19820401T000000455TZOFFSETFROM:+0300456TZOFFSETTO:+0400457X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow458END:DAYLIGHT459BEGIN:STANDARD460TZNAME:MSK461DTSTART:19821001T000000462TZOFFSETFROM:+0400463TZOFFSETTO:+0300464X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow465END:STANDARD466BEGIN:DAYLIGHT467TZNAME:MSD468DTSTART:19830401T000000469TZOFFSETFROM:+0300470TZOFFSETTO:+0400471X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow472END:DAYLIGHT473BEGIN:STANDARD474TZNAME:MSK475DTSTART:19831001T000000476TZOFFSETFROM:+0400477TZOFFSETTO:+0300478X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow479END:STANDARD480BEGIN:DAYLIGHT481TZNAME:MSD482DTSTART:19840401T000000483TZOFFSETFROM:+0300484TZOFFSETTO:+0400485X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow486END:DAYLIGHT487BEGIN:STANDARD488TZNAME:MSK489DTSTART:19840930T030000490TZOFFSETFROM:+0400491TZOFFSETTO:+0300492X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow493END:STANDARD494BEGIN:DAYLIGHT495TZNAME:MSD496DTSTART:19850331T020000497TZOFFSETFROM:+0300498TZOFFSETTO:+0400499X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow500END:DAYLIGHT501BEGIN:STANDARD502TZNAME:MSK503DTSTART:19850929T030000504TZOFFSETFROM:+0400505TZOFFSETTO:+0300506X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow507END:STANDARD508BEGIN:DAYLIGHT509TZNAME:MSD510DTSTART:19860330T020000511TZOFFSETFROM:+0300512TZOFFSETTO:+0400513X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow514END:DAYLIGHT515BEGIN:STANDARD516TZNAME:MSK517DTSTART:19860928T030000518TZOFFSETFROM:+0400519TZOFFSETTO:+0300520X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow521END:STANDARD522BEGIN:DAYLIGHT523TZNAME:MSD524DTSTART:19870329T020000525TZOFFSETFROM:+0300526TZOFFSETTO:+0400527X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow528END:DAYLIGHT529BEGIN:STANDARD530TZNAME:MSK531DTSTART:19870927T030000532TZOFFSETFROM:+0400533TZOFFSETTO:+0300534X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow535END:STANDARD536BEGIN:DAYLIGHT537TZNAME:MSD538DTSTART:19880327T020000539TZOFFSETFROM:+0300540TZOFFSETTO:+0400541X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow542END:DAYLIGHT543BEGIN:STANDARD544TZNAME:MSK545DTSTART:19880925T030000546TZOFFSETFROM:+0400547TZOFFSETTO:+0300548X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow549END:STANDARD550BEGIN:DAYLIGHT551TZNAME:MSD552DTSTART:19890326T020000553TZOFFSETFROM:+0300554TZOFFSETTO:+0400555X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow556END:DAYLIGHT557BEGIN:STANDARD558TZNAME:MSK559DTSTART:19890924T030000560TZOFFSETFROM:+0400561TZOFFSETTO:+0300562X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow563END:STANDARD564BEGIN:DAYLIGHT565TZNAME:MSD566DTSTART:19900325T020000567TZOFFSETFROM:+0300568TZOFFSETTO:+0400569X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow570END:DAYLIGHT571BEGIN:STANDARD572TZNAME:MSK573DTSTART:19900930T030000574TZOFFSETFROM:+0300575TZOFFSETTO:+0300576X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow577END:STANDARD578BEGIN:DAYLIGHT579TZNAME:EEST580DTSTART:19910331T020000581TZOFFSETFROM:+0200582TZOFFSETTO:+0300583X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow584END:DAYLIGHT585BEGIN:STANDARD586TZNAME:EET587DTSTART:19910929T030000588TZOFFSETFROM:+0300589TZOFFSETTO:+0200590X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow591END:STANDARD592BEGIN:STANDARD593TZNAME:MSK594DTSTART:19920119T020000595TZOFFSETFROM:+0400596TZOFFSETTO:+0300597X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow598END:STANDARD599BEGIN:DAYLIGHT600TZNAME:MSD601DTSTART:19920329T020000602TZOFFSETFROM:+0300603TZOFFSETTO:+0400604X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow605END:DAYLIGHT606BEGIN:STANDARD607TZNAME:MSK608DTSTART:19920927T030000609TZOFFSETFROM:+0400610TZOFFSETTO:+0300611X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow612END:STANDARD613BEGIN:DAYLIGHT614TZNAME:MSD615DTSTART:19930328T020000616TZOFFSETFROM:+0300617TZOFFSETTO:+0400618X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow619END:DAYLIGHT620BEGIN:STANDARD621TZNAME:MSK622DTSTART:19930926T030000623TZOFFSETFROM:+0400624TZOFFSETTO:+0300625X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow626END:STANDARD627BEGIN:DAYLIGHT628TZNAME:MSD629DTSTART:19940327T020000630TZOFFSETFROM:+0300631TZOFFSETTO:+0400632X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow633END:DAYLIGHT634BEGIN:STANDARD635TZNAME:MSK636DTSTART:19940925T030000637TZOFFSETFROM:+0400638TZOFFSETTO:+0300639X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow640END:STANDARD641BEGIN:DAYLIGHT642TZNAME:MSD643DTSTART:19950326T020000644TZOFFSETFROM:+0300645TZOFFSETTO:+0400646X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow647END:DAYLIGHT648BEGIN:STANDARD649TZNAME:MSK650DTSTART:19950924T030000651TZOFFSETFROM:+0400652TZOFFSETTO:+0300653X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow654END:STANDARD655BEGIN:DAYLIGHT656TZNAME:MSD657DTSTART:19960331T020000658TZOFFSETFROM:+0300659TZOFFSETTO:+0400660X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow661END:DAYLIGHT662BEGIN:STANDARD663TZNAME:MSK664DTSTART:19961027T030000665TZOFFSETFROM:+0400666TZOFFSETTO:+0300667X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow668END:STANDARD669BEGIN:DAYLIGHT670TZNAME:MSD671DTSTART:19970330T020000672TZOFFSETFROM:+0300673TZOFFSETTO:+0400674X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow675END:DAYLIGHT676BEGIN:STANDARD677TZNAME:MSK678DTSTART:19971026T030000679TZOFFSETFROM:+0400680TZOFFSETTO:+0300681X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow682END:STANDARD683BEGIN:DAYLIGHT684TZNAME:MSD685DTSTART:19980329T020000686TZOFFSETFROM:+0300687TZOFFSETTO:+0400688X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow689END:DAYLIGHT690BEGIN:STANDARD691TZNAME:MSK692DTSTART:19981025T030000693TZOFFSETFROM:+0400694TZOFFSETTO:+0300695X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow696END:STANDARD697BEGIN:DAYLIGHT698TZNAME:MSD699DTSTART:19990328T020000700TZOFFSETFROM:+0300701TZOFFSETTO:+0400702X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow703END:DAYLIGHT704BEGIN:STANDARD705TZNAME:MSK706DTSTART:19991031T030000707TZOFFSETFROM:+0400708TZOFFSETTO:+0300709X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow710END:STANDARD711BEGIN:DAYLIGHT712TZNAME:MSD713DTSTART:20000326T020000714TZOFFSETFROM:+0300715TZOFFSETTO:+0400716X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow717END:DAYLIGHT718BEGIN:STANDARD719TZNAME:MSK720DTSTART:20001029T030000721TZOFFSETFROM:+0400722TZOFFSETTO:+0300723X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow724END:STANDARD725BEGIN:DAYLIGHT726TZNAME:MSD727DTSTART:20010325T020000728TZOFFSETFROM:+0300729TZOFFSETTO:+0400730X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow731END:DAYLIGHT732BEGIN:STANDARD733TZNAME:MSK734DTSTART:20011028T030000735TZOFFSETFROM:+0400736TZOFFSETTO:+0300737X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow738END:STANDARD739BEGIN:DAYLIGHT740TZNAME:MSD741DTSTART:20020331T020000742TZOFFSETFROM:+0300743TZOFFSETTO:+0400744X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow745END:DAYLIGHT746BEGIN:STANDARD747TZNAME:MSK748DTSTART:20021027T030000749TZOFFSETFROM:+0400750TZOFFSETTO:+0300751X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow752END:STANDARD753BEGIN:DAYLIGHT754TZNAME:MSD755DTSTART:20030330T020000756TZOFFSETFROM:+0300757TZOFFSETTO:+0400758X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow759END:DAYLIGHT760BEGIN:STANDARD761TZNAME:MSK762DTSTART:20031026T030000763TZOFFSETFROM:+0400764TZOFFSETTO:+0300765X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow766END:STANDARD767BEGIN:DAYLIGHT768TZNAME:MSD769DTSTART:20040328T020000770TZOFFSETFROM:+0300771TZOFFSETTO:+0400772X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow773END:DAYLIGHT774BEGIN:STANDARD775TZNAME:MSK776DTSTART:20041031T030000777TZOFFSETFROM:+0400778TZOFFSETTO:+0300779X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow780END:STANDARD781BEGIN:DAYLIGHT782TZNAME:MSD783DTSTART:20050327T020000784TZOFFSETFROM:+0300785TZOFFSETTO:+0400786X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow787END:DAYLIGHT788BEGIN:STANDARD789TZNAME:MSK790DTSTART:20051030T030000791TZOFFSETFROM:+0400792TZOFFSETTO:+0300793X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow794END:STANDARD795BEGIN:DAYLIGHT796TZNAME:MSD797DTSTART:20060326T020000798TZOFFSETFROM:+0300799TZOFFSETTO:+0400800X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow801END:DAYLIGHT802BEGIN:STANDARD803TZNAME:MSK804DTSTART:20061029T030000805TZOFFSETFROM:+0400806TZOFFSETTO:+0300807X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow808END:STANDARD809BEGIN:DAYLIGHT810TZNAME:MSD811DTSTART:20070325T020000812TZOFFSETFROM:+0300813TZOFFSETTO:+0400814X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow815END:DAYLIGHT816BEGIN:STANDARD817TZNAME:MSK818DTSTART:20071028T030000819TZOFFSETFROM:+0400820TZOFFSETTO:+0300821X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow822END:STANDARD823BEGIN:DAYLIGHT824TZNAME:MSD825DTSTART:20080330T020000826TZOFFSETFROM:+0300827TZOFFSETTO:+0400828X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow829END:DAYLIGHT830BEGIN:STANDARD831TZNAME:MSK832DTSTART:20081026T030000833TZOFFSETFROM:+0400834TZOFFSETTO:+0300835X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow836END:STANDARD837BEGIN:DAYLIGHT838TZNAME:MSD839DTSTART:20090329T020000840TZOFFSETFROM:+0300841TZOFFSETTO:+0400842X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow843END:DAYLIGHT844BEGIN:STANDARD845TZNAME:MSK846DTSTART:20091025T030000847TZOFFSETFROM:+0400848TZOFFSETTO:+0300849X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow850END:STANDARD851BEGIN:DAYLIGHT852TZNAME:MSD853DTSTART:20100328T020000854TZOFFSETFROM:+0300855TZOFFSETTO:+0400856X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow857END:DAYLIGHT858BEGIN:STANDARD859TZNAME:MSK860DTSTART:20101031T030000861TZOFFSETFROM:+0400862TZOFFSETTO:+0300863X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow864END:STANDARD865BEGIN:STANDARD866TZNAME:MSK867DTSTART:20110327T020000868TZOFFSETFROM:+0300869TZOFFSETTO:+0400870X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow871END:STANDARD872BEGIN:STANDARD873TZNAME:MSK874DTSTART:20141026T020000875TZOFFSETFROM:+0400876TZOFFSETTO:+0300877X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow878END:STANDARD879X-RADICALE-NAME:/freeassociation.sourceforge.net/Europe/Moscow880END:VTIMEZONE881BEGIN:VEVENT882UID:20160729T101032Z-9313-1000-4291-10@localhost883DTSTAMP:20160729T063824Z884DTSTART;TZID=/freeassociation.sourceforge.net/Europe/Moscow:885 20160721T090000886DTEND;TZID=/freeassociation.sourceforge.net/Europe/Moscow:887 20160721T093000888SEQUENCE:2889SUMMARY:zzzzz890CLASS:PUBLIC891TRANSP:OPAQUE892CREATED:20160729T101116Z893LAST-MODIFIED:20160729T101116Z894X-RADICALE-NAME:20160729T101032Z-9313-1000-4291-10_localhost-20160729T101116Z.ics895END:VEVENT896END:VCALENDAR897'''),898 )899 # HEADERS = (900 # ical.Header('PRODID:-//Radicale//NONSGML Radicale Server//EN'),901 # ical.Header('VERSION:2.0'))902 TAG = 'VCALENDAR'903 maxDiff = None904 # def test_serialization(self):905 # name = '20160729T101032Z-9313-1000-4291-10_localhost-20160729T101116Z.ics'906 # for input_text, stored_text in self.DATA_CASES:907 # items = ical.Collection._parse(input_text, ICAL_TYPES, name)908 # self.assertEqual(name in items, True)909 # timezones = list(filter(910 # lambda x: x.tag == ical.Timezone.tag, items.values()))911 # serialized_text = ical.serialize(912 # self.TAG, self.HEADERS, [items[name]] + timezones)913 # self.assertEqual(serialized_text, stored_text)914 # items2 = ical.Collection._parse(serialized_text, ICAL_TYPES, name)...
sites.py
Source:sites.py
1"""2sites.py3Created by Daniel Magee on 2008-01-29.4Copyright (c) 2008 UCO/Lick Observatory. All rights reserved.5"""6import ephem as E7import math8class Site(object):9 """Observatory site class."""10 def __init__(self, siteid):11 try:12 self.siteid = siteid13 except KeyError:14 print 'ERROR: site %s not found.' % siteid15 16 def __setattr__(self, name, value):17 if name == 'siteid':18 object.__setattr__(self, name, value)19 if value is not None:20 for k,v in self._siteData[value].items():21 object.__setattr__(self, k, v)22 else:23 object.__setattr__(self, name, value)24 def observer(self):25 """Returns a pyephem Observer object for a site."""26 obs = E.Observer()27 obs.long = -1*E.degrees(self._siteData[self.siteid]['longitude'])28 obs.lat = E.degrees(self._siteData[self.siteid]['latitude'])29 obs.elevation = self._siteData[self.siteid]['elevation']30 obs.temp = self._siteData[self.siteid]['temperature']31 obs.pressure = self._siteData[self.siteid]['pressure']32 obs.epoch = 2000.033 obs.horizon = -1*math.sqrt(2*obs.elevation/E.earth_radius)34 return obs35 def sites(self):36 """Returns a list of sites."""37 sitekeys = self._siteData.keys()38 sitekeys.sort()39 site_names = []40 for s in sitekeys:41 site_names.append([s, self._siteData[s]['name']])42 return site_names43 44 45 _siteData = {46 #logitudes +W -E, latitudes +N -S47 'kpno' : {'name':'Kitt Peak National Observatory',48 'longitude':'111:36.0',49 'latitude':'31:57.8',50 'elevation':2120.,51 'temperature':15.0,52 'pressure':760.0,53 'timezone':'US/Mountain',54 'tzname':'Mountain'},55 'ctio' : {'name':'Cerro Tololo Interamerican Observatory',56 'longitude':'70:48:54.00',57 'latitude':'-30:09:55.00',58 'elevation':2215.,59 'temperature':7.0,60 'pressure':740.0,61 'timezone':'Chile/Continental',62 'tzname':'Chilean'},63 'lasilla' : {'name':'European Southern Observatory: La Silla',64 'longitude':'70:43.8',65 'latitude':'-29:15.4',66 'elevation':2347,67 'temperature':10.0,68 'pressure':770.0,69 'timezone':'Chile/Continental',70 'tzname':'Chilean'},71 'paranal' : {'name':'European Southern Observatory: Paranal',72 'longitude':'70:24.2',73 'latitude':'-24:37.5',74 'elevation':2635,75 'temperature':10.0,76 'pressure':750.0,77 'timezone':'Chile/Continental',78 'tzname':'Chilean'},79 'lick' : {'name':'Lick Observatory',80 'longitude':'121:38.2',81 'latitude':'37:20.6',82 'elevation':1290,83 'temperature':15.0,84 'pressure':1000.0,85 'timezone':'US/Pacific',86 'tzname':'Pacific'},87 'mmto' : {'name':'MMT Observatory',88 'longitude':'110:53.1',89 'latitude':'31:41.3',90 'elevation':2600,91 'temperature':14.0,92 'pressure':980.0,93 'timezone':'US/Mountain',94 'tzname':'Mountain'},95 'cfht' : {'name':'Canada-France-Hawaii Telescope',96 'longitude':'155:28.3',97 'latitude':'19:49.6',98 'elevation':4215,99 'temperature':0.0,100 'pressure':615.0,101 'timezone':'US/Hawaii',102 'tzname':'Hawaiian'},103 'lapalma' : {'name':'Roque de los Muchachos, La Palma',104 'longitude':'17:52.8',105 'latitude':'28:45.5',106 'elevation':2327,107 'temperature':8.0,108 'pressure':768.0,109 'timezone':'Atlantic/Canary',110 'tzname':'Canary Islands'},111 'mso' : {'name':'Mt. Stromlo Observatory',112 'longitude':'210:58:32.4',113 'latitude':'-35:19:14.34',114 'elevation':767,115 'temperature':15.0,116 'pressure':1010.0,117 'timezone':'Australia/Sydney',118 'tzname':'Australian'},119 'sso' : {'name':'Siding Spring Observatory',120 'longitude':'210:56:19.70',121 'latitude':'-31:16:24.10',122 'elevation':1149,123 'temperature':15.0,124 'pressure':1010.0,125 'timezone':'Australia/Sydney',126 'tzname':'Australian'},127 'aao' : {'name':'Anglo-Australian Observatory',128 'longitude':'210:56:2.09',129 'latitude':'-31:16:37.34',130 'elevation':1164,131 'temperature':15.0,132 'pressure':1010.0,133 'timezone':'Australia/Sydney',134 'tzname':'Australian'},135 'mcdonald' : {'name':'McDonald Observatory',136 'longitude':'104:01:18.00',137 'latitude':'30:40:18.00',138 'elevation':2075,139 'temperature':10.0,140 'pressure':800.0,141 'timezone':'US/Central',142 'tzname':'Central'},143 'lco' : {'name':'Las Campanas Observatory',144 'longitude':'70:42.1',145 'latitude':'-29:0.2',146 'elevation':2282,147 'temperature':7.0,148 'pressure':760.0,149 'timezone':'Chile/Continental',150 'tzname':'Chilean'},151 'mtbigelow' : {'name':'Catalina Observatory: 61 inch telescope',152 'longitude':'110:43.9',153 'latitude':'32:25.0',154 'elevation':2510.,155 'temperature':15.0,156 'pressure':1010.0,157 'timezone':'US/Mountain',158 'tzname':'Mountain'},159 'dao' : {'name':'Dominion Astrophysical Observatory',160 'longitude':'123:25.0',161 'latitude':'48:31.3',162 'elevation':229,163 'temperature':15.0,164 'pressure':1010.0,165 'timezone':'US/Pacific',166 'tzname':'Pacific'},167 'spm' : {'name':'Observatorio Astronomico Nacional, San Pedro Martir',168 'longitude':'115:29:13',169 'latitude':'31:01:45',170 'elevation':2830,171 'temperature':15.0,172 'pressure':1010.0,173 'timezone':'US/Pacific',174 'tzname':'Pacific'},175 'tona' : {'name':'Observatorio Astronomico Nacional, Tonantzintla',176 'longitude':'98:18:50',177 'latitude':'19:01:58',178 'elevation':0,179 'temperature':15.0,180 'pressure':1010.0,181 'timezone':'US/Central',182 'tzname':'Central'},183 'palomar' : {'name':'The Hale Telescope',184 'longitude':'116:51:46.80',185 'latitude':'33:21:21.6',186 'elevation':1706.,187 'temperature':15.0,188 'pressure':1010.0,189 'timezone':'US/Pacific',190 'tzname':'Pacific'},191 'mdm' : {'name':'Michigan-Dartmouth-MIT Observatory',192 'longitude':'111:37.0',193 'latitude':'31:57.0',194 'elevation':1938.5,195 'temperature':15.0,196 'pressure':760.0,197 'timezone':'US/Mountain',198 'tzname':'Mountain'},199 'bmo' : {'name':'Black Moshannon Observatory',200 'longitude':'78:00.3',201 'latitude':'40:55.3',202 'elevation':738,203 'temperature':15.0,204 'pressure':1010.0,205 'timezone':'US/Eastern',206 'tzname':'Eastern'},207 'keck' : {'name':'W. M. Keck Observatory',208 'longitude':'155:28:28.11',209 'latitude':'19:49:34.51',210 'elevation':4160,211 'temperature':0.0,212 'pressure':615.0,213 'timezone':'US/Hawaii',214 'tzname':'Hawaiian'},215 'subaru' : {'name':'Subaru Telescope',216 'longitude':'155:28:33.67',217 'latitude':'19:49:31.81',218 'elevation':4163,219 'temperature':0.0,220 'pressure':615.0,221 'timezone':'US/Hawaii',222 'tzname':'Hawaiian'},223 'apo' : {'name':'Apache Point Observatory',224 'longitude':'105:49.2',225 'latitude':'32:46.8',226 'elevation':2798.,227 'temperature':10.0,228 'pressure':760.0,229 'timezone':'US/Mountain',230 'tzname':'Mountain'},231 'lowell' : {'name':'Lowell Observatory',232 'longitude':'111:32.1',233 'latitude':'35:05.8',234 'elevation':2198.,235 'temperature':15.0,236 'pressure':1010.0,237 'timezone':'US/Mountain',238 'tzname':'Mountain'},239 'flwo' : {'name':'Whipple Observatory',240 'longitude':'110:52:39',241 'latitude':'31:40:51.4',242 'elevation':2320,243 'temperature':14.0,244 'pressure':980.0,245 'timezone':'US/Mountain',246 'tzname':'Mountain'},247 'irtf' : {'name':'NASA Infrared Telescope Facility',248 'longitude':'155:28:19.19564',249 'latitude':'19:49:34.38594',250 'elevation':4168,251 'temperature':0.0,252 'pressure':615.0,253 'timezone':'US/Hawaii',254 'tzname':'Hawaiian'},255 'gemini-north' : {'name':'Gemini North Observatory',256 'longitude':'155:28:08.56831',257 'latitude':'19:49:25.68521',258 'elevation':4213.4,259 'temperature':0.0,260 'pressure':615.0,261 'timezone':'US/Hawaii',262 'tzname':'Hawaiian'},263 'gemini-south' : {'name':'Gemini South Observatory',264 'longitude':'70:43.4',265 'latitude':'-30:13.7',266 'elevation':2737.,267 'temperature':5.0,268 'pressure':735.0,269 'timezone':'Chile/Continental',270 'tzname':'Chilean'},271 'esontt' : {'name':'European Southern Observatory, NTT, La Silla',272 'longitude':'70:43:54.272',273 'latitude':'-29:15:18.440',274 'elevation':2375,275 'temperature':10.0,276 'pressure':770.0,277 'timezone':'Chile/Continental',278 'tzname':'Chilean'},279 'eso36m' : {'name':'European Southern Observatory, 3.6m Telescope, La Silla',280 'longitude':'70:43:46.606',281 'latitude':'-29:15:25.814',282 'elevation':2400,283 'temperature':10.0,284 'pressure':770.0,285 'timezone':'Chile/Continental',286 'tzname':'Chilean'},287 'vlt' : {'name':'European Southern Observatory, VLT, Paranal',288 'longitude':'70:24:10.1',289 'latitude':'-24:37:31.5',290 'elevation':2648,291 'temperature':10.0,292 'pressure':750.0,293 'timezone':'Chile/Continental',294 'tzname':'Chilean'},295 'mgo' : {'name':'Mount Graham Observatory',296 'longitude':'109:53:30',297 'latitude':'32:42:06',298 'elevation':3181,299 'temperature':15.0,300 'pressure':760.0,301 'timezone':'US/Mountain',302 'tzname':'Mountain'}...
timezones.py
Source:timezones.py
...12}13class TimezoneCommands(commands.Cog, name="Timezones"):14 def __init__(self, bot):15 self.bot = bot16 def get_tzname(self, tzname):17 if tzname is None:18 return19 if tzname.upper() in COMMON_TIMEZONES:20 return COMMON_TIMEZONES[tzname.upper()]21 return tzname22 async def get_or_create_tz_role(self, guild, tzname):23 role = discord.utils.get(guild.roles, name=tzname)24 if role is not None:25 return role26 role = await guild.create_role(name=tzname, reason="Created timezone role.")27 return role28 @commands.command(name="selftimezone", aliases=["selftz", "mytz"])29 async def self_timezone(self, ctx, tzname=None):30 """31 Set your own default timezone.32 """33 tzname = self.get_tzname(tzname)34 if tzname is None:35 return await ctx.send(f"Usage: `{ctx.prefix}{ctx.command} <timezone name>`")36 if tzname not in pytz.all_timezones:37 return await ctx.send(38 "Not a valid timezone!\n"39 "Must be properly capitalized ex: US/Eastern, Asia/Kolkata etc.\n"40 "Here is a list of Timezones you can refer to: https://gist.github.com/heyalexej/8bf688fd67d7199be4a1682b3eec7568"41 )42 if tzname in pytz.all_timezones:43 database.set_tz(ctx.author.id, tzname)44 await ctx.send(f"Assigned timezone: {tzname}")45 @commands.command(name="time", aliases=["now"])46 async def get_time(self, ctx, tzname=None):47 """48 Get time for yourself or a member or for a timezone.49 """50 tzname = self.get_tzname(tzname)51 user = None52 if tzname not in pytz.all_timezones:53 if tzname is None:54 user = ctx.author55 elif len(ctx.message.mentions) > 0:56 user = ctx.message.mentions[0]57 else:58 user = discord.utils.find(59 lambda u: u.name.lower() == tzname.lower()60 or u.display_name.lower() == tzname.lower(),61 ctx.guild.members,62 )63 if user is None:64 return await ctx.send("No such user found!")65 tzname = database.get_tz(user.id)66 if tzname is None:67 if user == ctx.author:68 return await ctx.send(69 f"You do not have default timezone set! Use `{ctx.prefix}selftimezone`"70 )71 else:72 return await ctx.send(73 f"{user} does not have default timezone set! Use `{ctx.prefix}selftimezone`"74 )75 tz = pytz.timezone(tzname)76 tz_now = datetime.now(tz)77 if user is not None:78 msg = f"Current time for {user} (timezone: {tzname}) is:"79 else:80 msg = f"Current time for timezone {tzname} is:"81 fmt = "%Y-%m-%d %H:%M:%S"82 await ctx.send(83 f"{msg} {tz_now.strftime(fmt)}\nUTC Time: {datetime.utcnow().strftime(fmt)}"84 )85 @commands.command(name="convert")86 async def convert_time(self, ctx, dtstring=None, to=None, from_=None):87 """88 Convert time from one timezone to another.89 """90 if dtstring is None or to is None:91 return await ctx.send(92 f"Usage: `{ctx.prefix}{ctx.command} <datetime string> <to timezone> [optional: from timezone]`"93 )94 user_tzname = database.get_tz(ctx.author.id)95 if from_ is None and user_tzname is None:96 return await ctx.send(97 f"You do not have default timezone set! Use `{ctx.prefix}selftimezone`"98 )99 elif from_ is None:100 from_ = user_tzname101 from_ = self.get_tzname(from_)102 to = self.get_tzname(to)103 if from_ not in pytz.all_timezones or to not in pytz.all_timezones:104 return await ctx.send("Timezone doesn't exist!")105 dp = dateparser.DateDataParser(106 languages=["en"],107 settings={108 "TIMEZONE": from_,109 "RETURN_AS_TIMEZONE_AWARE": True,110 "RELATIVE_BASE": datetime.now(pytz.timezone(from_)),111 },112 )113 dateobj = dp.get_date_tuple(dtstring).date_obj114 if dateobj is None:115 return await ctx.send("Cannot parse date/time!")116 fmt = "%Y-%m-%d %H:%M:%S"...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!