Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

timezone tests

  • Loading branch information...
commit f8d3e025bdc3c1603c7abcde1f76d7aa551c1d3e 1 parent 02d92d3
Alon Levy authored
View
9 tests/timezone/README
@@ -0,0 +1,9 @@
+when fixing the icalendar file provided for the future committee events,
+these tests were useful.
+
+You need web.py - http://webpy.org/
+
+./ical.py
+
+./parse-webcal --url http://127.0.0.1:8080/Israel --text test
+./parse-webcal --url http://127.0.0.1:8080/UTC --text test
View
26 tests/timezone/ical.py
@@ -0,0 +1,26 @@
+import web
+import vobject
+import datetime
+from dateutil import zoneinfo
+
+urls = (
+ '/(.*)', 'hello'
+)
+app = web.application(urls, globals())
+
+def calendar(zone):
+ tz = zoneinfo.gettz(zone)
+ c = vobject.iCalendar()
+ v = c.add('vevent')
+ v.add('summary').value = 'test'
+ v.add('description').value = 'testdesc'
+ dtstart = datetime.datetime(year=2000, month=1, day=1, tzinfo=tz)
+ v.add('dtstart').value = dtstart
+ return c.serialize()
+
+class hello:
+ def GET(self, zone):
+ return calendar(zone)
+
+if __name__ == "__main__":
+ app.run()
View
24 tests/timezone/parse-webcal
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+# vim: set fileencoding=utf-8 :
+
+import vobject
+import urllib2
+import argparse
+import sys
+import commands
+
+parser = argparse.ArgumentParser()
+parser.add_argument('--url', default='http://localhost:8000/api/event/icalendar/')
+parser.add_argument('--text', default=u'הצעת חוק ההגבלים העסקיים')
+args = parser.parse_args(sys.argv[1:])
+
+print repr(args.url)
+urlfd = urllib2.urlopen(args.url)
+txt = urlfd.read()
+cal = vobject.readOne(txt)
+vevents = cal.contents['vevent']
+text = unicode(args.text, 'utf-8')
+for ve in vevents:
+ if text in ve.description.value:
+ print ve.dtstart
+ print(unicode.encode(ve.description.value, 'utf-8'))
Please sign in to comment.
Something went wrong with that request. Please try again.