~ubuntu-branches/ubuntu/wily/pymongo/wily-proposed

« back to all changes in this revision

Viewing changes to test/test_bulk.py

  • Committer: Package Import Robot
  • Author(s): Federico Ceratto
  • Date: 2014-09-28 11:54:48 UTC
  • mfrom: (24.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20140928115448-2j07tau6d9ye3s9o
Tags: 2.7.2-1
* New upstream release.
* Add architectures armel armhf mipsel ppc64el

Show diffs side-by-side

added added

removed removed

Lines of Context:
600
600
 
601
601
        self.assertEqual(1, self.coll.find({'x': 1}).count())
602
602
 
 
603
    def test_client_generated_upsert_id(self):
 
604
        batch = self.coll.initialize_ordered_bulk_op()
 
605
        batch.find({'_id': 0}).upsert().update_one({'$set': {'a': 0}})
 
606
        batch.find({'a': 1}).upsert().replace_one({'_id': 1})
 
607
        if not version.at_least(self.coll.database.connection, (2, 6, 0)):
 
608
            # This case is only possible in MongoDB versions before 2.6.
 
609
            batch.find({'_id': 3}).upsert().replace_one({'_id': 2})
 
610
        else:
 
611
            # This is just here to make the counts right in all cases.
 
612
            batch.find({'_id': 2}).upsert().replace_one({'_id': 2})
 
613
        result = batch.execute()
 
614
        self.assertEqualResponse(
 
615
            {'nMatched': 0,
 
616
             'nModified': 0,
 
617
             'nUpserted': 3,
 
618
             'nInserted': 0,
 
619
             'nRemoved': 0,
 
620
             'upserted': [{'index': 0, '_id': 0},
 
621
                          {'index': 1, '_id': 1},
 
622
                          {'index': 2, '_id': 2}]},
 
623
            result)
 
624
 
603
625
    def test_single_ordered_batch(self):
604
626
        batch = self.coll.initialize_ordered_bulk_op()
605
627
        batch.insert({'a': 1})