[CalendarServer-changes] [13419] CalendarServer/trunk/calendarserver/tools

source_changes at macosforge.org source_changes at macosforge.org
Fri May 2 19:17:35 PDT 2014


Revision: 13419
          http://trac.calendarserver.org//changeset/13419
Author:   sagen at apple.com
Date:     2014-05-02 19:17:35 -0700 (Fri, 02 May 2014)
Log Message:
-----------
Make sure we can handle the creation of locations and resources with no more than the full name

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/gateway.py
    CalendarServer/trunk/calendarserver/tools/test/test_gateway.py

Modified: CalendarServer/trunk/calendarserver/tools/gateway.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/gateway.py	2014-05-03 01:52:29 UTC (rev 13418)
+++ CalendarServer/trunk/calendarserver/tools/gateway.py	2014-05-03 02:17:35 UTC (rev 13419)
@@ -21,6 +21,7 @@
 import os
 from plistlib import readPlistFromString, writePlistToString
 import sys
+import uuid
 import xml
 
 from calendarserver.tools.cmdline import utilityMain
@@ -279,6 +280,10 @@
 
                 fields[field] = value
 
+        if FieldName.uid not in fields:
+            # No uid provided, so generate one
+            fields[FieldName.uid] = unicode(uuid.uuid4()).upper()
+
         if FieldName.shortNames not in fields:
             # No short names were provided, so copy from uid
             fields[FieldName.shortNames] = [fields[FieldName.uid]]

Modified: CalendarServer/trunk/calendarserver/tools/test/test_gateway.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/test/test_gateway.py	2014-05-03 01:52:29 UTC (rev 13418)
+++ CalendarServer/trunk/calendarserver/tools/test/test_gateway.py	2014-05-03 02:17:35 UTC (rev 13419)
@@ -302,6 +302,26 @@
 
 
     @inlineCallbacks
+    def test_createLocationMinimal(self):
+        """
+        Ensure we can create a location with just the bare minimum of values,
+        i.e. RealName
+        """
+
+        yield self.runCommand(command_createLocationMinimal)
+
+        # Tell the resources services to flush its cache and re-read XML
+        self._flush()
+
+        records = yield self.directory.recordsWithRecordType(self.directory.recordType.location)
+        for record in records:
+            if record.displayName == u"Minimal":
+                break
+        else:
+            self.fail("We did not find the Minimal record")
+
+
+    @inlineCallbacks
     def test_setLocationAttributes(self):
 
         yield self.runCommand(command_createLocation)
@@ -570,6 +590,19 @@
 """ % (unichr(208), u"\ud83d\udca3")
 
 
+command_createLocationMinimal = """<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+        <key>command</key>
+        <string>createLocation</string>
+        <key>RealName</key>
+        <string>Minimal</string>
+</dict>
+</plist>
+"""
+
+
 command_createResource = """<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140502/19fad61c/attachment.html>


More information about the calendarserver-changes mailing list