Commit a66533a2 by Dan Krause

Merge pull request #115 from felipe-lavratti/remove_field

Added Remove Field support on Object, including tests
parents 70d5343c 4c4b9fe7
...@@ -455,6 +455,19 @@ class Object(six.with_metaclass(ObjectMetaclass, ParseResource)): ...@@ -455,6 +455,19 @@ class Object(six.with_metaclass(ObjectMetaclass, ParseResource)):
} }
self.__class__.PUT(self._absolute_url, **payload) self.__class__.PUT(self._absolute_url, **payload)
self.__dict__[key] += amount self.__dict__[key] += amount
def remove(self, key):
"""
Clear a column value in the object. Note that this happens immediately:
it does not wait for save() to be called.
"""
payload = {
key: {
'__op': 'Delete'
}
}
self.__class__.PUT(self._absolute_url, **payload)
del self.__dict__[key]
def removeRelation(self, key, className, objectsId): def removeRelation(self, key, className, objectsId):
self.manageRelation('RemoveRelation', key, className, objectsId) self.manageRelation('RemoveRelation', key, className, objectsId)
......
...@@ -143,6 +143,12 @@ class TestObject(unittest.TestCase): ...@@ -143,6 +143,12 @@ class TestObject(unittest.TestCase):
self.score.increment('score') self.score.increment('score')
self.assertTrue(GameScore.Query.filter(score=previous_score + 1).exists(), self.assertTrue(GameScore.Query.filter(score=previous_score + 1).exists(),
'Failed to increment score on backend') 'Failed to increment score on backend')
def testCanRemoveField(self):
self.score.save()
self.score.remove('score')
self.assertTrue(GameScore.Query.filter(score=None).exists(),
'Failed to remove score on backend')
def testAssociatedObject(self): def testAssociatedObject(self):
"""test saving and associating a different object""" """test saving and associating a different object"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment