Package caldavclientlibrary :: Package protocol :: Package caldav :: Package tests :: Module test_makecalendar
[hide private]
[frames] | no frames]

Source Code for Module caldavclientlibrary.protocol.caldav.tests.test_makecalendar

  1  ## 
  2  # Copyright (c) 2006-2016 Apple Inc. All rights reserved. 
  3  # 
  4  # Licensed under the Apache License, Version 2.0 (the "License"); 
  5  # you may not use this file except in compliance with the License. 
  6  # You may obtain a copy of the License at 
  7  # 
  8  # http://www.apache.org/licenses/LICENSE-2.0 
  9  # 
 10  # Unless required by applicable law or agreed to in writing, software 
 11  # distributed under the License is distributed on an "AS IS" BASIS, 
 12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 13  # See the License for the specific language governing permissions and 
 14  # limitations under the License. 
 15  ## 
 16   
 17  from caldavclientlibrary.protocol.webdav.session import Session 
 18  from caldavclientlibrary.protocol.caldav.makecalendar import MakeCalendar 
 19  from StringIO import StringIO 
 20  import unittest 
 21   
22 -class TestRequest(unittest.TestCase):
23
24 - def test_Method(self):
25 26 server = Session("www.example.com") 27 request = MakeCalendar(server, "/") 28 self.assertEqual(request.getMethod(), "MKCALENDAR")
29
30 -class TestRequestHeaders(unittest.TestCase):
31 pass
32
33 -class TestRequestBody(unittest.TestCase):
34
36 37 server = Session("www.example.com") 38 request = MakeCalendar(server, "/", "home") 39 os = StringIO() 40 request.generateXML(os) 41 self.assertEqual(os.getvalue(), """<?xml version='1.0' encoding='utf-8'?> 42 <ns0:mkcalendar xmlns:ns0="urn:ietf:params:xml:ns:caldav"> 43 <ns1:prop xmlns:ns1="DAV:"> 44 <ns1:displayname>home</ns1:displayname> 45 </ns1:prop> 46 </ns0:mkcalendar> 47 """.replace("\n", "\r\n") 48 )
49
51 52 server = Session("www.example.com") 53 request = MakeCalendar(server, "/", "home", "my personal calendar") 54 os = StringIO() 55 request.generateXML(os) 56 self.assertEqual(os.getvalue(), """<?xml version='1.0' encoding='utf-8'?> 57 <ns0:mkcalendar xmlns:ns0="urn:ietf:params:xml:ns:caldav"> 58 <ns1:prop xmlns:ns1="DAV:"> 59 <ns1:displayname>home</ns1:displayname> 60 <ns0:calendar-description>my personal calendar</ns0:calendar-description> 61 </ns1:prop> 62 </ns0:mkcalendar> 63 """.replace("\n", "\r\n") 64 )
65
67 68 server = Session("www.example.com") 69 timezone = """BEGIN:VCALENDAR 70 PRODID:-//Example Corp.//CalDAV Client//EN 71 VERSION:2.0 72 BEGIN:VTIMEZONE 73 TZID:US-Eastern 74 LAST-MODIFIED:19870101T000000Z 75 BEGIN:STANDARD 76 DTSTART:19671029T020000 77 RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 78 TZOFFSETFROM:-0400 79 TZOFFSETTO:-0500 80 TZNAME:Eastern Standard Time (US & Canada) 81 END:STANDARD 82 BEGIN:DAYLIGHT 83 DTSTART:19870405T020000 84 RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 85 TZOFFSETFROM:-0500 86 TZOFFSETTO:-0400 87 TZNAME:Eastern Daylight Time (US & Canada) 88 END:DAYLIGHT 89 END:VTIMEZONE 90 END:VCALENDAR 91 """.replace("\n", "\r\n") 92 request = MakeCalendar(server, "/", timezone=timezone) 93 os = StringIO() 94 request.generateXML(os) 95 self.assertEqual(os.getvalue(), """<?xml version='1.0' encoding='utf-8'?> 96 <ns0:mkcalendar xmlns:ns0="urn:ietf:params:xml:ns:caldav"> 97 <ns1:prop xmlns:ns1="DAV:"> 98 <ns0:calendar-timezone>%s</ns0:calendar-timezone> 99 </ns1:prop> 100 </ns0:mkcalendar> 101 """.replace("\n", "\r\n") % (timezone.replace("&", "&amp;"),) 102 )
103
104 -class TestResponse(unittest.TestCase):
105 pass
106
107 -class TestResponseHeaders(unittest.TestCase):
108 pass
109
110 -class TestResponseBody(unittest.TestCase):
111 pass
112