| 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.http.session import Session 18 from caldavclientlibrary.protocol.webdav.lock import Lock 19 from caldavclientlibrary.protocol.webdav.definitions import headers 20 from StringIO import StringIO 21 22 import unittest 23 313384 8535 36 server = Session("www.example.com") 37 request = Lock(server, "/", headers.Depth0, Lock.eExclusive, "user@example.com", -1, exists=Lock.eResourceMayExist) 38 hdrs = request.generateRequestHeader() 39 self.assertFalse("If-None-Match:" in hdrs) 40 self.assertFalse("If-Match:" in hdrs)4143 44 server = Session("www.example.com") 45 request = Lock(server, "/", headers.Depth0, Lock.eExclusive, "user@example.com", -1, exists=Lock.eResourceMustExist) 46 hdrs = request.generateRequestHeader() 47 self.assertFalse("If-None-Match:" in hdrs) 48 self.assertTrue("If-Match: *" in hdrs)4951 52 server = Session("www.example.com") 53 request = Lock(server, "/", headers.Depth0, Lock.eExclusive, "user@example.com", -1, exists=Lock.eResourceMustNotExist) 54 hdrs = request.generateRequestHeader() 55 self.assertTrue("If-None-Match: *" in hdrs) 56 self.assertFalse("If-Match:" in hdrs)5759 60 server = Session("www.example.com") 61 request = Lock(server, "/", headers.Depth0, Lock.eExclusive, "user@example.com", -1, exists=Lock.eResourceMustNotExist) 62 hdrs = request.generateRequestHeader() 63 self.assertTrue("Depth: 0" in hdrs) 64 self.assertFalse("Depth: 1" in hdrs) 65 self.assertFalse("Depth: infinity" in hdrs)6668 69 server = Session("www.example.com") 70 request = Lock(server, "/", headers.Depth1, Lock.eExclusive, "user@example.com", -1, exists=Lock.eResourceMustNotExist) 71 hdrs = request.generateRequestHeader() 72 self.assertFalse("Depth: 0" in hdrs) 73 self.assertTrue("Depth: 1" in hdrs) 74 self.assertFalse("Depth: infinity" in hdrs)7577 78 server = Session("www.example.com") 79 request = Lock(server, "/", headers.DepthInfinity, Lock.eExclusive, "user@example.com", -1, exists=Lock.eResourceMustNotExist) 80 hdrs = request.generateRequestHeader() 81 self.assertFalse("Depth: 0" in hdrs) 82 self.assertFalse("Depth: 1" in hdrs) 83 self.assertTrue("Depth: infinity" in hdrs)87106 10989 90 server = Session("www.example.com") 91 request = Lock(server, "/", headers.Depth0, Lock.eExclusive, "user@example.com", -1) 92 os = StringIO() 93 request.generateXML(os) 94 self.assertEqual(os.getvalue(), """<?xml version='1.0' encoding='utf-8'?> 95 <ns0:lockinfo xmlns:ns0="DAV:"> 96 <ns0:lockscope> 97 <ns0:exclusive /> 98 </ns0:lockscope> 99 <ns0:locktype> 100 <ns0:write /> 101 </ns0:locktype> 102 <ns0:owner>user@example.com</ns0:owner> 103 </ns0:lockinfo> 104 """.replace("\n", "\r\n") 105 )111120113 114 server = Session("www.example.com") 115 request = Lock(server, "/", headers.Depth0, Lock.eExclusive, "user@example.com", -1) 116 request.getResponseHeaders().update({ 117 "Lock-Token": ("<user@example.com>",), 118 }) 119 self.assertEqual(request.getLockToken(), "user@example.com")
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Thu Jul 7 15:01:47 2011 | http://epydoc.sourceforge.net |