Package caldavclientlibrary :: Package admin :: Package xmlaccounts :: Package tests :: Module test_directory
[hide private]
[frames] | no frames]

Source Code for Module caldavclientlibrary.admin.xmlaccounts.tests.test_directory

 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 StringIO import StringIO 
18  from caldavclientlibrary.admin.xmlaccounts.directory import XMLDirectory 
19  from caldavclientlibrary.protocol.utils.xmlhelpers import BetterElementTree 
20  from xml.etree.ElementTree import XML 
21   
22  import unittest 
23   
24 -class TestDirectory(unittest.TestCase):
25
26 - def checkXML(self, x):
27 28 x = x.replace("\n", "\r\n") 29 30 # Parse the XML data 31 a = XMLDirectory() 32 a.parseXML(XML(x)) 33 34 # Generate the XML data 35 node = a.writeXML() 36 os = StringIO() 37 xmldoc = BetterElementTree(node) 38 xmldoc.writeUTF8(os) 39 40 # Verify data 41 self.assertEqual(os.getvalue(), x)
42
43 - def test_accounts(self):
44 45 self.checkXML("""<?xml version='1.0' encoding='utf-8'?> 46 <accounts realm="Test Realm"> 47 <user> 48 <uid>admin</uid> 49 <guid>12345</guid> 50 <password>admin</password> 51 <name>Super User</name> 52 </user> 53 <user> 54 <uid>test</uid> 55 <guid /> 56 <password>test</password> 57 <name>Test User</name> 58 <cuaddr>mailto:testuser@example.com</cuaddr> 59 </user> 60 <group> 61 <uid>users</uid> 62 <guid>123456</guid> 63 <password>users</password> 64 <name>Users Group</name> 65 <members> 66 <member type="users">test</member> 67 </members> 68 </group> 69 <location> 70 <uid>mercury</uid> 71 <guid>1234567</guid> 72 <password>mercury</password> 73 <name>Mecury Conference Room, Building 1, 2nd Floor</name> 74 <auto-schedule /> 75 <proxies> 76 <member type="users">test</member> 77 </proxies> 78 </location> 79 </accounts> 80 """)
81