Package caldavclientlibrary :: Package protocol :: Package webdav :: Package tests :: Module test_principalmatch
[hide private]
[frames] | no frames]

Source Code for Module caldavclientlibrary.protocol.webdav.tests.test_principalmatch

 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.principalmatch import PrincipalMatch 
19  from StringIO import StringIO 
20  from caldavclientlibrary.protocol.webdav.definitions import davxml 
21  import unittest 
22   
23 -class TestRequest(unittest.TestCase):
24
25 - def test_Method(self):
26 27 server = Session("www.example.com") 28 request = PrincipalMatch(server, "/", ()) 29 self.assertEqual(request.getMethod(), "REPORT")
30
31 -class TestRequestHeaders(unittest.TestCase):
32
33 - def test_Depth0Headers(self):
34 35 server = Session("www.example.com") 36 request = PrincipalMatch(server, "/", ()) 37 hdrs = request.generateRequestHeader() 38 self.assertTrue("Depth: 0" in hdrs) 39 self.assertFalse("Depth: 1" in hdrs) 40 self.assertFalse("Depth: infinity" in hdrs)
41
42 -class TestRequestBody(unittest.TestCase):
43
45 46 server = Session("www.example.com") 47 request = PrincipalMatch(server, "/", (davxml.getetag,)) 48 os = StringIO() 49 request.generateXML(os) 50 self.assertEqual(os.getvalue(), """<?xml version='1.0' encoding='utf-8'?> 51 <ns0:principal-match xmlns:ns0="DAV:"> 52 <ns0:self /> 53 <ns0:prop> 54 <ns0:getetag /> 55 </ns0:prop> 56 </ns0:principal-match> 57 """.replace("\n", "\r\n") 58 )
59
61 62 server = Session("www.example.com") 63 request = PrincipalMatch(server, "/", (davxml.getetag, davxml.displayname,)) 64 os = StringIO() 65 request.generateXML(os) 66 self.assertEqual(os.getvalue(), """<?xml version='1.0' encoding='utf-8'?> 67 <ns0:principal-match xmlns:ns0="DAV:"> 68 <ns0:self /> 69 <ns0:prop> 70 <ns0:getetag /> 71 <ns0:displayname /> 72 </ns0:prop> 73 </ns0:principal-match> 74 """.replace("\n", "\r\n") 75 )
76
77 -class TestResponse(unittest.TestCase):
78 pass
79
80 -class TestResponseHeaders(unittest.TestCase):
81 pass
82
83 -class TestResponseBody(unittest.TestCase):
84 pass
85