[CalendarServer-changes] [11233] CalendarServer/trunk/twistedcaldav/directory
source_changes at macosforge.org
source_changes at macosforge.org
Tue May 21 14:26:16 PDT 2013
Revision: 11233
http://trac.calendarserver.org//changeset/11233
Author: sagen at apple.com
Date: 2013-05-21 14:26:16 -0700 (Tue, 21 May 2013)
Log Message:
-----------
When normalizing the augments records, remove the previous versions
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/directory/augment.py
CalendarServer/trunk/twistedcaldav/directory/test/test_augment.py
Added Paths:
-----------
CalendarServer/trunk/twistedcaldav/directory/test/augments-normalization.xml
Modified: CalendarServer/trunk/twistedcaldav/directory/augment.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/augment.py 2013-05-21 17:48:17 UTC (rev 11232)
+++ CalendarServer/trunk/twistedcaldav/directory/augment.py 2013-05-21 21:26:16 UTC (rev 11233)
@@ -109,7 +109,7 @@
old = yield self._lookupAugmentRecord(uid)
new = copy.deepcopy(old)
new.uid = uid.upper()
- remove.append(old)
+ remove.append(uid)
add.append(new)
try:
yield self.removeAugmentRecords(remove)
@@ -404,8 +404,8 @@
"""
Remove AugmentRecords with the specified UIDs.
- @param uid: directory UID to lookup
- @type uid: C{list} of C{str}
+ @param uids: list of uids to remove
+ @type uids: C{list} of C{str}
@return: L{Deferred}
"""
@@ -610,7 +610,15 @@
@inlineCallbacks
def removeAugmentRecords(self, uids):
+ """
+ Remove AugmentRecords with the specified UIDs.
+ @param uids: list of uids to remove
+ @type uids: C{list} of C{str}
+
+ @return: L{Deferred}
+ """
+
for uid in uids:
yield self.execute("delete from AUGMENTS where UID = :1", (uid,))
Added: CalendarServer/trunk/twistedcaldav/directory/test/augments-normalization.xml
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/augments-normalization.xml (rev 0)
+++ CalendarServer/trunk/twistedcaldav/directory/test/augments-normalization.xml 2013-05-21 21:26:16 UTC (rev 11233)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+Copyright (c) 2009-2013 Apple Inc. All rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+ -->
+
+<!DOCTYPE accounts SYSTEM "../../../conf/auth/augments.dtd">
+
+<augments>
+ <record>
+ <uid>aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa</uid>
+ <enable>true</enable>
+ </record>
+</augments>
Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_augment.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_augment.py 2013-05-21 17:48:17 UTC (rev 11232)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_augment.py 2013-05-21 21:26:16 UTC (rev 11233)
@@ -23,9 +23,13 @@
import cStringIO
import os
from twext.python.filepath import CachingFilePath as FilePath
+from twistedcaldav.xmlutil import readXML
+from twistedcaldav.directory import xmlaugmentsparser
+
xmlFile = os.path.join(os.path.dirname(__file__), "augments-test.xml")
xmlFileDefault = os.path.join(os.path.dirname(__file__), "augments-test-default.xml")
+xmlFileNormalization = os.path.join(os.path.dirname(__file__), "augments-normalization.xml")
testRecords = (
{"uid":"D11F03A0-97EA-48AF-9A6C-FAC7F3975766", "enabled":True, "partitionID":"", "enabledForCalendaring":False, "enabledForAddressBooks":False, "autoSchedule":False, "autoScheduleMode":"default"},
@@ -300,6 +304,30 @@
dbxml.refresh()
self.assertEquals(keys, dbxml.db.keys())
+ def uidsFromFile(self, filename):
+ """
+ Return all uids from the augments xml file
+ """
+
+ _ignore_etree, augments_node = readXML(filename)
+ for record_node in augments_node.getchildren():
+ if record_node.tag != xmlaugmentsparser.ELEMENT_RECORD:
+ continue
+ uid = record_node.find(xmlaugmentsparser.ELEMENT_UID).text
+ yield uid
+
+ def test_normalize(self):
+ """
+ Ensure augment uids are normalized upon opening
+ """
+ newxmlfile = FilePath(self.mktemp())
+ FilePath(xmlFileNormalization).copyTo(newxmlfile)
+ uids = list(self.uidsFromFile(newxmlfile.path))
+ self.assertEquals(uids, ['aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'])
+ AugmentXMLDB((newxmlfile.path,))
+ uids = list(self.uidsFromFile(newxmlfile.path))
+ self.assertEquals(uids, ['AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA'])
+
class AugmentSqliteTests(AugmentTests, AugmentTestsMixin):
def _db(self, dbpath=None):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130521/2df7fadf/attachment.html>
More information about the calendarserver-changes
mailing list