[Checkins] SVN: Products.GenericSetup/branches/1.3/Products/GenericSetup/ Provide default for dependencies when processing metadata.xml, to avoid a

Tres Seaver tseaver at palladion.com
Wed Aug 6 12:49:21 EDT 2008


Log message for revision 89452:
  Provide default for dependencies when processing metadata.xml, to avoid a
  KeyError.  (https://bugs.launchpad.net/zope-cmf/+bug/255301)
  

Changed:
  U   Products.GenericSetup/branches/1.3/Products/GenericSetup/CHANGES.txt
  U   Products.GenericSetup/branches/1.3/Products/GenericSetup/metadata.py
  U   Products.GenericSetup/branches/1.3/Products/GenericSetup/tests/test_profile_metadata.py

-=-
Modified: Products.GenericSetup/branches/1.3/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/branches/1.3/Products/GenericSetup/CHANGES.txt	2008-08-06 16:48:46 UTC (rev 89451)
+++ Products.GenericSetup/branches/1.3/Products/GenericSetup/CHANGES.txt	2008-08-06 16:49:19 UTC (rev 89452)
@@ -2,6 +2,10 @@
 
   GenericSetup 1.3.4 (unreleased)
 
+    - Provide default for dependencies when processing metadata.xml, to
+      avoid a KeyError.
+      (https://bugs.launchpad.net/zope-cmf/+bug/255301)
+
     - During object manager imports do not throw an error when
       trying to remove an object that was already removed.
 

Modified: Products.GenericSetup/branches/1.3/Products/GenericSetup/metadata.py
===================================================================
--- Products.GenericSetup/branches/1.3/Products/GenericSetup/metadata.py	2008-08-06 16:48:46 UTC (rev 89451)
+++ Products.GenericSetup/branches/1.3/Products/GenericSetup/metadata.py	2008-08-06 16:49:19 UTC (rev 89452)
@@ -12,7 +12,7 @@
 ##############################################################################
 """ GenericSetup profile metadata
 
-$Id:$
+$Id$
 """
 import os
 
@@ -54,7 +54,7 @@
             { '#text': { KEY: None },
               },
             'dependencies':
-            {'dependency': { KEY: None },},
+            {'dependency': { KEY: None, DEFAULT: () },},
             'dependency':
             { '#text': { KEY: None },
               },

Modified: Products.GenericSetup/branches/1.3/Products/GenericSetup/tests/test_profile_metadata.py
===================================================================
--- Products.GenericSetup/branches/1.3/Products/GenericSetup/tests/test_profile_metadata.py	2008-08-06 16:48:46 UTC (rev 89451)
+++ Products.GenericSetup/branches/1.3/Products/GenericSetup/tests/test_profile_metadata.py	2008-08-06 16:49:19 UTC (rev 89452)
@@ -12,7 +12,7 @@
 ##############################################################################
 """ Unit tests for ProfileMetadata.
 
-$Id:$
+$Id$
 """
 import unittest
 import os
@@ -46,6 +46,20 @@
     'dependencies': (dep1, dep2),
     }
 
+_METADATA_EMPTY_DEPENDENCIES_XML = """<?xml version="1.0"?>
+<metadata>
+  <description>%s</description>
+  <version>%s</version>
+  <dependencies></dependencies>
+</metadata>
+""" % (desc, version)
+
+_METADATA_MAP_EMPTY_DEPENDENCIES = {
+    'description': desc,
+    'version': version,
+    'dependencies': (),
+    }
+
 class ProfileMetadataTests( ZopeTestCase ):
 
     installProduct('GenericSetup')
@@ -70,6 +84,12 @@
         product = getattr(self.app.Control_Panel.Products, product_name)
         self.assertEqual(profile_info['version'], product.version)
 
+    def test_parseXML_empty_dependencies(self):
+        # https://bugs.launchpad.net/bugs/255301
+        metadata = ProfileMetadata( '')
+        parsed = metadata.parseXML(_METADATA_EMPTY_DEPENDENCIES_XML)
+        self.assertEqual(parsed, _METADATA_MAP_EMPTY_DEPENDENCIES)
+
 def test_suite():
     return unittest.TestSuite((
         unittest.makeSuite( ProfileMetadataTests ),



More information about the Checkins mailing list