コード例 #1
0
ファイル: test_batch.py プロジェクト: bcoe/mongate
 def test_batch_update(self):
     self._perform_batch_insertion()
     
     batch = Batch(self.collection, self.connection)
     
     batch.add_update(
         {
             'batch_insert_1': 3
         },
         {
             "$inc": {
                 "bar": 1
             }
         }
     )
     
     batch.add_update(
         {
             'batch_insert_2': 'banana'
         },
         {
             '$set': {
                 'banana': 'tasty'
             }
         }
     )
     
     batch.execute()
     
     retrieved_document_1, retrieved_document_2 = self._retrieve_documents()
     
     self.assertEqual(3, retrieved_document_1['bar']) 
     self.assertEqual('tasty', retrieved_document_2['banana'])
コード例 #2
0
ファイル: test_batch.py プロジェクト: bcoe/mongate
 def test_batch_update_with_invalid_characters(self):
     self._perform_batch_insertion()
     
     batch = Batch(self.collection, self.connection)
     
     batch.add_update(
         {
             'batch_insert_1': 3
         },
         {
             "$inc": {
                 "bar": 1
             }
         }
     )
     
     exception = False
     try:
         batch.execute()
     except Exception:
         exception = True
         
     self.assertFalse(exception)