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

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

 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.record import XMLRecord 
19  from caldavclientlibrary.protocol.utils.xmlhelpers import BetterElementTree 
20  from xml.etree.ElementTree import XML 
21   
22  import unittest 
23   
24 -class TestRecord(unittest.TestCase):
25
26 - def checkXML(self, x):
27 28 x = x.replace("\n", "\r\n") 29 30 # Parse the XML data 31 a = XMLRecord() 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_user(self):
44 45 self.checkXML("""<?xml version='1.0' encoding='utf-8'?> 46 <user> 47 <uid>test</uid> 48 <guid /> 49 <password>test</password> 50 <name>Test User</name> 51 <cuaddr>mailto:testuser@example.com</cuaddr> 52 </user> 53 """)
54
55 - def test_group(self):
56 57 self.checkXML("""<?xml version='1.0' encoding='utf-8'?> 58 <group> 59 <uid>users</uid> 60 <guid>12345</guid> 61 <password>users</password> 62 <name>Users Group</name> 63 <members> 64 <member type="users">test</member> 65 </members> 66 </group> 67 """)
68
69 - def test_location(self):
70 71 self.checkXML("""<?xml version='1.0' encoding='utf-8'?> 72 <location> 73 <uid>mercury</uid> 74 <guid>12345</guid> 75 <password>mercury</password> 76 <name>Mecury Conference Room, Building 1, 2nd Floor</name> 77 <auto-schedule /> 78 <proxies> 79 <member type="users">test</member> 80 </proxies> 81 </location> 82 """)
83