| Home | Trees | Indices | Help |
|---|
|
|
1 ## 2 # Copyright (c) 2007-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.webdav.propfind import PropFind 19 from StringIO import StringIO 20 from caldavclientlibrary.protocol.webdav.definitions import davxml 21 from xml.etree.ElementTree import QName 22 from caldavclientlibrary.protocol.webdav.definitions import headers 23 import unittest 24 32346136 37 server = Session("www.example.com") 38 request = PropFind(server, "/", headers.Depth0, (davxml.getetag, QName("http://example.com/ns/", "taggy"))) 39 hdrs = request.generateRequestHeader() 40 self.assertTrue("Depth: 0" in hdrs) 41 self.assertFalse("Depth: 1" in hdrs) 42 self.assertFalse("Depth: infinity" in hdrs)4345 46 server = Session("www.example.com") 47 request = PropFind(server, "/", headers.Depth1, (davxml.getetag, QName("http://example.com/ns/", "taggy"))) 48 hdrs = request.generateRequestHeader() 49 self.assertFalse("Depth: 0" in hdrs) 50 self.assertTrue("Depth: 1" in hdrs) 51 self.assertFalse("Depth: infinity" in hdrs)5254 55 server = Session("www.example.com") 56 request = PropFind(server, "/", headers.DepthInfinity, (davxml.getetag, QName("http://example.com/ns/", "taggy"))) 57 hdrs = request.generateRequestHeader() 58 self.assertFalse("Depth: 0" in hdrs) 59 self.assertFalse("Depth: 1" in hdrs) 60 self.assertTrue("Depth: infinity" in hdrs)6379 82 85 8865 66 server = Session("www.example.com") 67 request = PropFind(server, "/", headers.Depth0, (davxml.getetag, QName("http://example.com/ns/", "taggy"))) 68 os = StringIO() 69 request.generateXML(os) 70 self.assertEqual(os.getvalue(), """<?xml version='1.0' encoding='utf-8'?> 71 <ns0:propfind xmlns:ns0="DAV:"> 72 <ns0:prop> 73 <ns0:getetag /> 74 <ns1:taggy xmlns:ns1="http://example.com/ns/" /> 75 </ns0:prop> 76 </ns0:propfind> 77 """.replace("\n", "\r\n") 78 )
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Thu Jul 7 15:01:47 2011 | http://epydoc.sourceforge.net |