From 5ccbfd9be45de1a2b2c53c03106b301d8820dc25 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Tue, 27 Jul 2010 15:18:04 +0000
Subject: [PATCH] Fix testICal that was wrongly depending on machine timezone.
 When we render a DATE-TIME, we are using "FORM #2: DATE WITH UTC TIME" as
 defined by rfc2445, which means a date in UTC timezone. The test was setting
 dates using machine timezone, and later comparing the UTC rendering with
 those machine's timezone dates. Change the test to simply set UTC dates on
 documents.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37295 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/tests/testICal.py | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/product/ERP5/tests/testICal.py b/product/ERP5/tests/testICal.py
index 5d8eec6ed6..c439b8c312 100644
--- a/product/ERP5/tests/testICal.py
+++ b/product/ERP5/tests/testICal.py
@@ -25,20 +25,6 @@
 #
 ##############################################################################
 
-"""
-  TIMEZONE WARNING
-  The ICal renderer does not take into account time zones, because clients can take care about it
-  for themselves, so we use GMT time.
-  This test assumes the person running the test is in the same time zone as me, which is usually true.
-  It will be fixed some day.
-  
-  I have been investigating this a little, DateTime module caches the timezone
-  very early in the initialisation process, so changing os.environ['TZ'] has
-  no effect. For now, the easiest is to set TZ environ variable to something
-  like 'Europe/France'
-
-"""
-
 import unittest
 
 import transaction
@@ -142,14 +128,14 @@ class TestICal(ERP5TypeTestCase):
     
     # set start date, description and change workflow state - new
     event.receive()
-    event.setStartDate('2007/08/15 10:30')
+    event.setStartDate('2007/08/15 08:30 UTC')
     event.setDescription('Event One description')
     transaction.commit()
     self.tic()
     
     feed_dict = self.getICalFeed(module)
-    self.assertEquals( # if this fail for you, try to set $TZ to Europe/Paris
-        feed_dict['DTSTART'], '20070815T083000Z')
+    # DSTART and DTEND are the date in UTC
+    self.assertEquals(feed_dict['DTSTART'], '20070815T083000Z')
     # if not set end date, it must be same as start date
     self.assertEquals(feed_dict['DTEND'], '20070815T083000Z')
     self.assertEquals(feed_dict['STATUS'], 'TENTATIVE')
@@ -166,7 +152,7 @@ class TestICal(ERP5TypeTestCase):
     
     # set stop date and change workflow state - assigned
     event.assign()
-    event.setStopDate('2007/08/15 15:30')
+    event.setStopDate('2007/08/15 13:30 UTC')
     transaction.commit()
     self.tic()
     
-- 
2.30.9