Monotone-Parent: e9d4010d6c952c0aa503fa4571a589fb91c356b5
Monotone-Revision: b6518b59a7eb387bb26b065aa4b947048534a96a Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-07-13T17:36:32 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
10059831ab
commit
9afaff4af4
|
@ -1,5 +1,11 @@
|
||||||
2010-07-13 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2010-07-13 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* Tests/Integration/test-put.py: new test module executing X puts
|
||||||
|
based on a number of auto-generated events configured in config.py
|
||||||
|
|
||||||
|
* Tests/Integration/ev_generator.py: new module producing
|
||||||
|
auto-generated events based on a number of days
|
||||||
|
|
||||||
* Tests/Integration/sogotests.py: new module overriding
|
* Tests/Integration/sogotests.py: new module overriding
|
||||||
certain methods from the "unittest" module in order to
|
certain methods from the "unittest" module in order to
|
||||||
automatically execute the tests in verbose mode and by displaying
|
automatically execute the tests in verbose mode and by displaying
|
||||||
|
|
|
@ -13,3 +13,5 @@ attendee1 = "user@domain.com"
|
||||||
attendee1_delegate = "otheruser@domain.com"
|
attendee1_delegate = "otheruser@domain.com"
|
||||||
|
|
||||||
mailserver = "imaphost"
|
mailserver = "imaphost"
|
||||||
|
|
||||||
|
testput_nbrdays = 30
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
import time
|
||||||
|
|
||||||
|
def hours(nbr):
|
||||||
|
return nbr * 3600
|
||||||
|
|
||||||
|
def days(nbr):
|
||||||
|
return nbr * hours(24)
|
||||||
|
|
||||||
|
class ev_generator:
|
||||||
|
ev_templ = """
|
||||||
|
BEGIN:VCALENDAR\r
|
||||||
|
VERSION:2.0\r
|
||||||
|
PRODID:-//Inverse//Event Generator//EN\r
|
||||||
|
CALSCALE:GREGORIAN\r
|
||||||
|
BEGIN:VTIMEZONE\r
|
||||||
|
TZID:America/Montreal\r
|
||||||
|
BEGIN:DAYLIGHT\r
|
||||||
|
TZOFFSETFROM:-0500\r
|
||||||
|
TZOFFSETTO:-0400\r
|
||||||
|
DTSTART:20070311T020000\r
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU\r
|
||||||
|
TZNAME:EDT\r
|
||||||
|
END:DAYLIGHT\r
|
||||||
|
BEGIN:STANDARD\r
|
||||||
|
TZOFFSETFROM:-0400\r
|
||||||
|
TZOFFSETTO:-0500\r
|
||||||
|
DTSTART:20071104T020000\r
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU\r
|
||||||
|
TZNAME:EST\r
|
||||||
|
END:STANDARD\r
|
||||||
|
END:VTIMEZONE\r
|
||||||
|
BEGIN:VEVENT\r
|
||||||
|
SEQUENCE:4\r
|
||||||
|
TRANSP:OPAQUE\r
|
||||||
|
UID:%(uid)s\r
|
||||||
|
SUMMARY:%(summary)s\r
|
||||||
|
DTSTART;TZID=America/Montreal:%(start)s\r
|
||||||
|
DTEND;TZID=America/Montreal:%(end)s\r
|
||||||
|
CREATED:20080711T231608Z\r
|
||||||
|
DTSTAMP:20080711T231640Z\r
|
||||||
|
END:VEVENT\r
|
||||||
|
END:VCALENDAR\r
|
||||||
|
"""
|
||||||
|
def __init__(self, maxDays):
|
||||||
|
self.reset(maxDays)
|
||||||
|
|
||||||
|
def reset(self, maxDays):
|
||||||
|
self.maxDays = maxDays
|
||||||
|
self.currentDay = 0
|
||||||
|
self.currentStart = 0
|
||||||
|
today = time.mktime(time.localtime())
|
||||||
|
self.firstDay = today - days(maxDays + 30)
|
||||||
|
|
||||||
|
def _calendarDate(self, eventTime):
|
||||||
|
timeStruct = time.localtime(eventTime)
|
||||||
|
return time.strftime("%Y%m%dT%H0000", timeStruct)
|
||||||
|
|
||||||
|
def _iterValues(self):
|
||||||
|
event = None
|
||||||
|
|
||||||
|
if (self.currentDay < self.maxDays):
|
||||||
|
eventStart = (self.firstDay
|
||||||
|
+ days(self.currentDay)
|
||||||
|
+ hours(self.currentStart + 8))
|
||||||
|
eventEnd = eventStart + hours(1)
|
||||||
|
|
||||||
|
thatDay = time.localtime(int(eventStart))
|
||||||
|
uid = "Event%d%d" % (eventStart, eventEnd)
|
||||||
|
summary = "%s - event %d" % (time.strftime("%Y-%m-%d", thatDay),
|
||||||
|
self.currentStart)
|
||||||
|
start = self._calendarDate(eventStart)
|
||||||
|
end = self._calendarDate(eventEnd)
|
||||||
|
event = {'uid': uid,
|
||||||
|
'summary': summary,
|
||||||
|
'start': start,
|
||||||
|
'end': end}
|
||||||
|
|
||||||
|
self.currentStart = self.currentStart + 1
|
||||||
|
if (self.currentStart > 7):
|
||||||
|
self.currentStart = 0
|
||||||
|
self.currentDay = self.currentDay + 1
|
||||||
|
|
||||||
|
return event
|
||||||
|
|
||||||
|
def iter(self):
|
||||||
|
hasMore = False
|
||||||
|
entryValues = self._iterValues()
|
||||||
|
if (entryValues is not None):
|
||||||
|
self.event = (self.ev_templ % entryValues).strip()
|
||||||
|
hasMore = True
|
||||||
|
|
||||||
|
return hasMore
|
|
@ -0,0 +1,42 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
from config import hostname, port, username, password, testput_nbrdays
|
||||||
|
|
||||||
|
import ev_generator
|
||||||
|
import sogotests
|
||||||
|
import unittest
|
||||||
|
import webdavlib
|
||||||
|
|
||||||
|
class HTTPUnparsedURLTest(unittest.TestCase):
|
||||||
|
def __init__(self, arg):
|
||||||
|
unittest.TestCase.__init__(self, arg)
|
||||||
|
self.client = webdavlib.WebDAVClient(hostname, port,
|
||||||
|
username, password)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.resource = '/SOGo/dav/%s/Calendar/test-dav-put/' % username
|
||||||
|
delete = webdavlib.WebDAVDELETE(self.resource)
|
||||||
|
self.client.execute(delete)
|
||||||
|
mkcol = webdavlib.WebDAVMKCOL(self.resource)
|
||||||
|
self.client.execute(mkcol)
|
||||||
|
self.assertEquals(mkcol.response["status"], 201,
|
||||||
|
"preparation: failure creating collection"
|
||||||
|
"(code = %d)" % mkcol.response["status"])
|
||||||
|
|
||||||
|
def testPUT(self):
|
||||||
|
gen = ev_generator.ev_generator(testput_nbrdays)
|
||||||
|
counter = 1
|
||||||
|
while gen.iter():
|
||||||
|
event = gen.event
|
||||||
|
url = self.resource + "event-%d.ics" % counter
|
||||||
|
put = webdavlib.HTTPPUT(url, event)
|
||||||
|
put.content_type = "text/calendar; charset=utf-8"
|
||||||
|
self.client.execute(put)
|
||||||
|
counter = counter + 1
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
delete = webdavlib.WebDAVDELETE(self.resource)
|
||||||
|
self.client.execute(delete)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sogotests.runTests()
|
Loading…
Reference in New Issue