chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpo...@apache.org
Subject svn commit: r926385 - in /incubator/chemistry/trunk/cmislib/src: cmislib/model.py tests/cmislibtest.py
Date Mon, 22 Mar 2010 23:04:39 GMT
Author: jpotts
Date: Mon Mar 22 23:04:39 2010
New Revision: 926385

URL: http://svn.apache.org/viewvc?rev=926385&view=rev
Log:
Resolved the following CMIS Jira issues: CMIS-158 (fixed support for non-ascii properties),
CMIS-159 (order is now maintained on query results rather than being keyed off of object ID),
CMIS-169 (removed testDuplicateFolder), CMIS-170 (modified testPropertyFilter to not look
for the absence of filtered properties).

Modified:
    incubator/chemistry/trunk/cmislib/src/cmislib/model.py
    incubator/chemistry/trunk/cmislib/src/tests/cmislibtest.py

Modified: incubator/chemistry/trunk/cmislib/src/cmislib/model.py
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/cmislib/src/cmislib/model.py?rev=926385&r1=926384&r2=926385&view=diff
==============================================================================
--- incubator/chemistry/trunk/cmislib/src/cmislib/model.py (original)
+++ incubator/chemistry/trunk/cmislib/src/cmislib/model.py Mon Mar 22 23:04:39 2010
@@ -1337,11 +1337,11 @@ class ResultSet():
 
     def __iter__(self):
         ''' Iterator for the result set '''
-        return self.getResults().itervalues()
+        return iter(self.getResults())
 
     def __getitem__(self, index):
         ''' Getter for the result set '''
-        return self.getResults().values()[index]
+        return self.getResults()[index]
 
     def __len__(self):
         ''' Len method for the result set '''
@@ -1411,17 +1411,23 @@ class ResultSet():
 
         if self._xmlDoc:
             entryElements = self._xmlDoc.getElementsByTagNameNS(ATOM_NS, 'entry')
-            entries = {}
+            entries = []
             for entryElement in entryElements:
                 cmisObject = getSpecializedObject(CmisObject(self._cmisClient,
                                                              self._repository,
                                                              xmlDoc=entryElement))
-                entries[cmisObject.getObjectId()] = cmisObject
+                entries.append(cmisObject)
 
             self._results = entries
 
         return self._results
 
+    def hasObject(self, objectId):
+        for obj in self.getResults():
+            if obj.id == objectId:
+                return True
+        return False
+
     def getFirst(self):
 
         '''
@@ -3765,7 +3771,7 @@ def parsePropValue(value, nodeName):
     if nodeName == 'propertyId':
         return CmisId(value)
     elif nodeName == 'propertyString':
-        return str(value)
+        return value
     elif nodeName == 'propertyBoolean':
         bDict = {'false': False, 'true': True}
         return bDict[value.lower()]

Modified: incubator/chemistry/trunk/cmislib/src/tests/cmislibtest.py
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/cmislib/src/tests/cmislibtest.py?rev=926385&r1=926384&r2=926385&view=diff
==============================================================================
--- incubator/chemistry/trunk/cmislib/src/tests/cmislibtest.py (original)
+++ incubator/chemistry/trunk/cmislib/src/tests/cmislibtest.py Mon Mar 22 23:04:39 2010
@@ -477,6 +477,11 @@ class FolderTest(CmisTestBase):
         parentFolder = self._testFolder.createFolder(parentFolderName)
         subFolder = parentFolder.createFolder(subFolderName)
 
+        # Per CMIS-170, CMIS providers are not required to filter the
+        # properties returned. So these tests will check only for the presence
+        # of the properties asked for, not the absence of properties that
+        # should be filtered if the server chooses to do so.
+
         # test when used with getObjectByPath
         searchFolder = self._repo.getObjectByPath(settings.TEST_ROOT_PATH + \
                         "/".join([testFolderName, parentFolderName, subFolderName]), \
@@ -485,7 +490,6 @@ class FolderTest(CmisTestBase):
         self.assertTrue(searchFolder.getProperties().has_key('cmis:objectId'))
         self.assertTrue(searchFolder.getProperties().has_key('cmis:objectTypeId'))
         self.assertTrue(searchFolder.getProperties().has_key('cmis:baseTypeId'))
-        self.assertFalse(searchFolder.getProperties().has_key('cmis:name'))
 
         # test when used with getObjectByPath + reload
         searchFolder = self._repo.getObjectByPath(settings.TEST_ROOT_PATH + \
@@ -496,7 +500,6 @@ class FolderTest(CmisTestBase):
         self.assertTrue(searchFolder.getProperties().has_key('cmis:objectId'))
         self.assertTrue(searchFolder.getProperties().has_key('cmis:objectTypeId'))
         self.assertTrue(searchFolder.getProperties().has_key('cmis:baseTypeId'))
-        self.assertFalse(searchFolder.getProperties().has_key('cmis:name'))
 
         # test when used with getObject
         searchFolder = self._repo.getObject(subFolder.getObjectId(), \
@@ -505,7 +508,6 @@ class FolderTest(CmisTestBase):
         self.assertTrue(searchFolder.getProperties().has_key('cmis:objectId'))
         self.assertTrue(searchFolder.getProperties().has_key('cmis:objectTypeId'))
         self.assertTrue(searchFolder.getProperties().has_key('cmis:baseTypeId'))
-        self.assertFalse(searchFolder.getProperties().has_key('cmis:name'))
 
         # test when used with getObject + reload
         searchFolder = self._repo.getObject(subFolder.getObjectId(), \
@@ -515,7 +517,6 @@ class FolderTest(CmisTestBase):
         self.assertTrue(searchFolder.getProperties().has_key('cmis:objectId'))
         self.assertTrue(searchFolder.getProperties().has_key('cmis:objectTypeId'))
         self.assertTrue(searchFolder.getProperties().has_key('cmis:baseTypeId'))
-        self.assertFalse(searchFolder.getProperties().has_key('cmis:name'))
 
         # test that you can do a reload with a reset filter
         searchFolder.reload(filter='*')
@@ -568,16 +569,18 @@ class FolderTest(CmisTestBase):
                           firstFolder.createFolder,
                           'bad parent')
 
-    def testDuplicateFolder(self):
-        '''Try to create a folder that already exists'''
-        folderName = 'testDupFolder folder'
-        firstFolder = self._testFolder.createFolder(folderName)
-        self.assert_('cmis:objectId' in firstFolder.getProperties())
-        # really, this needs to be ContentAlreadyExistsException but
-        # not all CMIS providers report it as such
-        self.assertRaises(CmisException,
-                          self._testFolder.createFolder,
-                          folderName)
+# Per CMIS-169, nothing in the spec says that an exception should be thrown
+# when a duplicate folder is created, so this test is really not necessary.
+#    def testDuplicateFolder(self):
+#        '''Try to create a folder that already exists'''
+#        folderName = 'testDupFolder folder'
+#        firstFolder = self._testFolder.createFolder(folderName)
+#        self.assert_('cmis:objectId' in firstFolder.getProperties())
+#        # really, this needs to be ContentAlreadyExistsException but
+#        # not all CMIS providers report it as such
+#        self.assertRaises(CmisException,
+#                          self._testFolder.createFolder,
+#                          folderName)
 
 
 class ChangeEntryTest(CmisTestBase):
@@ -1159,7 +1162,7 @@ def isInResultSet(resultSet, targetDoc):
     """
     done = False
     while not done:
-        if resultSet.getResults().has_key(targetDoc.getObjectId()):
+        if resultSet.hasObject(targetDoc.getObjectId()):
             return True
         if resultSet.hasNext():
             resultSet.getNext()



Mime
View raw message