Vo Minh Thu (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-server/trunk-caldavng-rlo into lp:openobject-server.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-caldavng-rlo/+merge/96114
-- 
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-caldavng-rlo/+merge/96114
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-server/trunk-caldavng-rlo.
=== modified file 'openerp/tests/__init__.py'
--- openerp/tests/__init__.py	2012-03-01 13:46:08 +0000
+++ openerp/tests/__init__.py	2012-03-06 13:11:21 +0000
@@ -21,4 +21,8 @@
     test_orm,
     ]
 
+# This test suite checks the caldav functionalities
+def make_suite_caldav():
+    suite = unittest2.TestSuite()
+    suite.addTests(unittest2.TestLoader().loadTestsFromModule(test_caldav))
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'openerp/tests/test_caldav.py'
--- openerp/tests/test_caldav.py	1970-01-01 00:00:00 +0000
+++ openerp/tests/test_caldav.py	2012-03-06 13:11:21 +0000
@@ -0,0 +1,150 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import caldav
+import unittest2
+from caldav.elements import dav
+from datetime import datetime, timedelta
+
+
+USER = 'admin'
+PASS = 'admin'
+DB = 'openerp_6'
+SERVER_HOST = 'localhost'
+SERVER_PORT = 8069
+SERVER_PATH = '/webdav/%(db)s/calendars/users/%(user)s/c/Meetings/' % {'db': DB, 'user': USER}
+CLIENT_AGENT = 'Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111229 Thunderbird/9.0 Lightning/1.1'
+URL = 'http://%(user)s:%(pass)s@%(host)s:%(port)d%(path)s' % {
+    'user': USER, 'pass': PASS, 'host': SERVER_HOST, 
+    'port': SERVER_PORT, 'path': SERVER_PATH
+}
+
+# message to the caldav server, to create an event
+NEW_EVENT = '''
+BEGIN:VCALENDAR
+PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
+VERSION:2.0
+BEGIN:VTIMEZONE
+TZID:Europe/Brussels
+X-LIC-LOCATION:Europe/Brussels
+BEGIN:DAYLIGHT
+TZOFFSETFROM:+0100
+TZOFFSETTO:+0200
+TZNAME:CEST
+DTSTART:19700329T020000
+RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
+END:DAYLIGHT
+BEGIN:STANDARD
+TZOFFSETFROM:+0200
+TZOFFSETTO:+0100
+TZNAME:CET
+DTSTART:19701025T030000
+RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+CREATED:20120203T134304Z
+LAST-MODIFIED:20120203T134318Z
+DTSTAMP:20120203T134318Z
+UID:dafe7553-8430-49aa-acb1-1f74b5d52f72
+SUMMARY:New Event
+DTSTART;TZID=Europe/Brussels:%(year)04d%(month)02d%(day)02dT%(hour)02d%(min)02d%(sec)02d
+DTEND;TZID=Europe/Brussels:%(yearend)04d%(monthend)02d%(dayend)02dT%(hourend)02d%(minend)02d%(secend)02d
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+'''
+
+NEW_CALENDAR_XML = '''
+<?xml version='1.0' encoding='utf-8'?>
+<D:mkcol xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:D="DAV:">
+  <D:set>
+    <D:prop>
+      <D:resourcetype>
+        <D:collection>
+          <C:calendar-collection/>
+        </D:collection>
+      </D:resourcetype>
+      <D:displayname>Yep
+    </D:prop>
+  </D:set>
+</D:mkcol>
+'''
+
+# import pdb
+
+class test_caldav(unittest2.TestCase):
+    '''Some tests for crud operations over caldav'''
+
+    def setUp(self):
+        self.client = caldav.DAVClient(URL)
+        principal = caldav.Principal(self.client, URL)
+
+        print principal.url
+
+        from caldav.elements import dav, cdav
+
+        c = []
+        depth = 1
+        properties = {}
+        props = [dav.ResourceType(), ]
+        prop = dav.Prop() + props
+        root = dav.Propfind() + prop
+
+        print props, prop, root
+
+        if principal.calendars() != None:
+            print principal.calendars()
+        calendars = principal.calendars()
+        if len(calendars) == 0:
+            r = self.client.mkcol(URL, NEW_CALENDAR_XML)
+            print 'calresponse: '
+            print r
+        print 'calendars: '
+        print calendars
+        self.now = datetime.now()
+        self.delta = timedelta(hours=1)
+        # 0.- check there's a calendar available and pick the 1st one.
+        assert len(calendars) > 0, 'There isn\'t any calendar available.\n Please, check the URL'
+        self.cal = calendars[0]
+        self.numevts = len(self.cal.events())
+
+    def test_caldav_creation_deletion(self):
+        '''Small test to check events creation and deletion'''
+        # 1.- create an event
+        # pdb.set_trace()
+        enddate = self.now + self.delta
+        numevts = len(self.cal.date_search(self.now, enddate))
+        evt = caldav.Event(self.client, data = NEW_EVENT % {
+            'year': self.now.year, 'month': self.now.month, 'day': self.now.day, 
+            'hour': self.now.hour, 'min': self.now.minute, 'sec': self.now.second,
+            'yearend': enddate.year, 'monthend': enddate.month, 'dayend': enddate.day, 
+            'hourend': enddate.hour, 'minend': enddate.minute, 'secend': enddate.second
+        }, parent = self.cal).save()
+        # 2.- check creation
+        assert len(self.cal.date_search(self.now, enddate)) > numevts, 'Creation failed'
+        numevts = len(self.cal.date_search(self.now, enddate))
+        # 3.- delete event
+        self.cal.event(evt.id).delete()
+        # 4.- check deletion
+        assert len(self.cal.date_search(self.now, enddate)) < numevts, 'Delete failed'
+
+    def test_caldav_propfind(self):
+        '''Small test to check the correct behavior of the propfind operation'''
+        # 0.- check number of previously existing events
+        enddate = self.now + self.delta
+        numevts = len(self.cal.date_search(self.now, enddate))
+        # 1.- create an event
+        evt = caldav.Event(self.client, data = NEW_EVENT % {
+            'year': self.now.year, 'month': self.now.month, 'day': self.now.day,
+            'hour': self.now.hour, 'min': self.now.minute, 'sec': self.now.second,
+            'yearend': enddate.year, 'monthend': enddate.month, 'dayend': enddate.day, 
+            'hourend': enddate.hour, 'minend': enddate.minute, 'secend': enddate.second
+        }, parent = self.cal).save()
+        # 2.- Test if created or not
+        assert len(self.cal.date_search(self.now, enddate)) == numevts + 1, 'Propfind failed'
+        # 3.- Delete the event
+        self.cal.event(evt.id).delete()
+
+if __name__=='__main__':
+    unittest2.main()

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to