'Test the bulk_upsert method.'

def test_bulk_upsert(self):

    docs = ({'_id': i} for i in range(1000))
    self.choosy_docman.bulk_upsert(docs, *TESTARGS)
    res = list(self._search(sort=[('_id', 1)]))
    self.assertEqual(len(res), 1000)
    for (i, r) in enumerate(res):
        self.assertEqual(r['_id'], i)
    docs = ({'_id': i, 'weight': (2 * i)} for i in range(1000))
    self.choosy_docman.bulk_upsert(docs, *TESTARGS)
    res = list(self._search(sort=[('_id', 1)]))
    self.assertEqual(len(res), 1000)
    for (i, r) in enumerate(res):
        self.assertEqual(r['weight'], (2 * i))
