You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by jp...@apache.org on 2016/09/02 22:31:12 UTC
svn commit: r1759041 - in /chemistry/cmislib/trunk/src:
cmislib/browser/binding.py tests/cmislibtest.py
Author: jpotts
Date: Fri Sep 2 22:31:12 2016
New Revision: 1759041
URL: http://svn.apache.org/viewvc?rev=1759041&view=rev
Log:
Change log entry related tests are now successful for the browser binding. Also made a change to ignore logic for repositories that return None instead of none for the change capability.
Modified:
chemistry/cmislib/trunk/src/cmislib/browser/binding.py
chemistry/cmislib/trunk/src/tests/cmislibtest.py
Modified: chemistry/cmislib/trunk/src/cmislib/browser/binding.py
URL: http://svn.apache.org/viewvc/chemistry/cmislib/trunk/src/cmislib/browser/binding.py?rev=1759041&r1=1759040&r2=1759041&view=diff
==============================================================================
--- chemistry/cmislib/trunk/src/cmislib/browser/binding.py (original)
+++ chemistry/cmislib/trunk/src/cmislib/browser/binding.py Fri Sep 2 22:31:12 2016
@@ -25,7 +25,7 @@ from cmislib.domain import CmisId, CmisO
from cmislib.exceptions import CmisException, InvalidArgumentException,\
NotSupportedException, ObjectNotFoundException
from cmislib.net import RESTService as Rest
-from cmislib.util import parsePropValueByType
+from cmislib.util import parsePropValueByType, parseDateTimeValue
import json
import logging
import StringIO
@@ -587,7 +587,7 @@ class BrowserRepository(object):
def __str__(self):
"""To string"""
- return self.getRepositoryName()
+ return self.getRepositoryId()
def _initData(self):
"""
@@ -1241,7 +1241,7 @@ class BrowserRepository(object):
if self.getCapabilities()['Changes'] is None:
raise NotSupportedException(messages.NO_CHANGE_LOG_SUPPORT)
- changesUrl = self.getRootFolderUrl() + "?selector=contentChanges"
+ changesUrl = self.getRepositoryUrl() + "?cmisselector=contentChanges"
result = self._cmisClient.binding.get(changesUrl,
self._cmisClient.username,
@@ -2871,17 +2871,23 @@ class BrowserChangeEntry(ChangeEntry):
def getId(self):
"""
- Returns the unique ID of the change entry.
- """
- # TODO need to implement
- pass
+ Returns the unique ID of the change entry. This is not actually required
+ by the spec and is absent in the browser binding for the Apache chemistry
+ in-memory repository.
+ """
+ if self._changeEntryId is None:
+ if 'id' in self._data.keys():
+ self._changeEntryId = self._data.get('id')
+ return self._changeEntryId
def getObjectId(self):
"""
Returns the object ID of the object that changed.
"""
- # TODO need to implement
- pass
+ if self._objectId is None:
+ if 'cmis:objectId' in self._data.get('properties').keys():
+ self._objectId = self._data.get('properties').get('cmis:objectId').get('value')
+ return self._objectId
def getChangeType(self):
@@ -2894,8 +2900,10 @@ class BrowserChangeEntry(ChangeEntry):
- deleted
- security
"""
- # TODO need to implement
- pass
+ if self._changeType is None:
+ self._changeType = self._data.get('changeEventInfo').get('changeType')
+
+ return self._changeType
def getACL(self):
@@ -2910,8 +2918,11 @@ class BrowserChangeEntry(ChangeEntry):
"""
Returns a datetime object representing the time the change occurred.
"""
- # TODO need to implement
- pass
+ if self._changeTime is None:
+ if 'changeTime' in self._data.get('changeEventInfo').keys():
+ self._changeTime = self._data.get('changeEventInfo').get('changeTime')
+
+ return parseDateTimeValue(self._changeTime)
def getProperties(self):
@@ -2920,8 +2931,19 @@ class BrowserChangeEntry(ChangeEntry):
capabilities of the repository ("capabilityChanges") the list may not
include the actual property values that changed.
"""
- # TODO need to implement
- pass
+ if not self._properties:
+ props = self._data.get('properties')
+ for prop in self._data.get('properties').itervalues():
+ # property could be multi-valued
+ if type(prop['value']) is list:
+ propVal = []
+ for val in prop['value']:
+ propVal.append(parsePropValueByType(val, prop['type']))
+ self._properties[prop['id']] = propVal
+ else:
+ self._properties[prop['id']] = parsePropValueByType(prop['value'], prop['type'])
+
+ return self._properties
id = property(getId)
objectId = property(getObjectId)
@@ -3305,10 +3327,9 @@ class ChangeEntrySerializer(object):
entries = []
for obj in jsonObj['objects']:
self.logger.debug("Parsing a change entry object")
- dataObj = obj['object']
- cmisObject = getSpecializedObject(BrowserChangeEntry(client,
- repo,
- data=dataObj))
+ cmisObject = BrowserChangeEntry(client,
+ repo,
+ data=obj)
self.logger.debug("Parsed a change entry object, appending")
entries.append(cmisObject)
Modified: chemistry/cmislib/trunk/src/tests/cmislibtest.py
URL: http://svn.apache.org/viewvc/chemistry/cmislib/trunk/src/tests/cmislibtest.py?rev=1759041&r1=1759040&r2=1759041&view=diff
==============================================================================
--- chemistry/cmislib/trunk/src/tests/cmislibtest.py (original)
+++ chemistry/cmislib/trunk/src/tests/cmislibtest.py Fri Sep 2 22:31:12 2016
@@ -734,7 +734,7 @@ class ChangeEntryTest(CmisTestBase):
# need to check changes capability
changeCap = self._repo.capabilities['Changes']
- if changeCap == 'none':
+ if changeCap == None or changeCap == 'none':
print messages.NO_CHANGE_LOG_SUPPORT
return
@@ -743,7 +743,7 @@ class ChangeEntryTest(CmisTestBase):
rs = self._repo.getContentChanges()
self.assertTrue(len(rs) > 0)
changeEntry = rs[0]
- self.assertTrue(changeEntry.id)
+ self.assertTrue(changeEntry.objectId)
self.assertTrue(changeEntry.changeType in ['created', 'updated', 'deleted', 'security'])
self.assertTrue(changeEntry.changeTime)
@@ -753,7 +753,7 @@ class ChangeEntryTest(CmisTestBase):
# need to check changes capability
changeCap = self._repo.capabilities['Changes']
- if changeCap == 'none':
+ if changeCap == None or changeCap == 'none':
print messages.NO_CHANGE_LOG_SUPPORT
return
@@ -792,7 +792,7 @@ class ChangeEntryTest(CmisTestBase):
# need to check changes capability
changeCap = self._repo.capabilities['Changes']
- if changeCap == 'none':
+ if changeCap == None or changeCap == 'none':
print messages.NO_CHANGE_LOG_SUPPORT
return