Skip to content

Commit f8d3e02

Browse files
author
Alon Levy
committed
timezone tests
1 parent 02d92d3 commit f8d3e02

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

Diff for: tests/timezone/README

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
when fixing the icalendar file provided for the future committee events,
2+
these tests were useful.
3+
4+
You need web.py - http://webpy.org/
5+
6+
./ical.py
7+
8+
./parse-webcal --url http://127.0.0.1:8080/Israel --text test
9+
./parse-webcal --url http://127.0.0.1:8080/UTC --text test

Diff for: tests/timezone/ical.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import web
2+
import vobject
3+
import datetime
4+
from dateutil import zoneinfo
5+
6+
urls = (
7+
'/(.*)', 'hello'
8+
)
9+
app = web.application(urls, globals())
10+
11+
def calendar(zone):
12+
tz = zoneinfo.gettz(zone)
13+
c = vobject.iCalendar()
14+
v = c.add('vevent')
15+
v.add('summary').value = 'test'
16+
v.add('description').value = 'testdesc'
17+
dtstart = datetime.datetime(year=2000, month=1, day=1, tzinfo=tz)
18+
v.add('dtstart').value = dtstart
19+
return c.serialize()
20+
21+
class hello:
22+
def GET(self, zone):
23+
return calendar(zone)
24+
25+
if __name__ == "__main__":
26+
app.run()

Diff for: tests/timezone/parse-webcal

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python
2+
# vim: set fileencoding=utf-8 :
3+
4+
import vobject
5+
import urllib2
6+
import argparse
7+
import sys
8+
import commands
9+
10+
parser = argparse.ArgumentParser()
11+
parser.add_argument('--url', default='http://localhost:8000/api/event/icalendar/')
12+
parser.add_argument('--text', default=u'הצעת חוק ההגבלים העסקיים')
13+
args = parser.parse_args(sys.argv[1:])
14+
15+
print repr(args.url)
16+
urlfd = urllib2.urlopen(args.url)
17+
txt = urlfd.read()
18+
cal = vobject.readOne(txt)
19+
vevents = cal.contents['vevent']
20+
text = unicode(args.text, 'utf-8')
21+
for ve in vevents:
22+
if text in ve.description.value:
23+
print ve.dtstart
24+
print(unicode.encode(ve.description.value, 'utf-8'))

0 commit comments

Comments
 (0)