def test_save(self): # A save differs from an insert in that it may perform an insert or it # may perform an update, depending on whether an _id exists doc1 = {'x': 1, 'y': 1} doc2 = {'x': 2, 'y': 1} operations.multishard_save('dummy', doc1) operations.multishard_save('dummy', doc2) doc1['z'] = 10 doc2['z'] = 20 operations.multishard_save('dummy', doc1) operations.multishard_save('dummy', doc2) results = list(self.db1.dummy.find({'y': 1})) self.assertEquals([doc1], results) results = list(self.db2.dummy.find({'y': 1})) self.assertEquals([doc2], results)
def save(self, *args, **kwargs): return operations.multishard_save( self.collection_name, *args, **kwargs)