'Test the dump_collection method with invalid documents.
Cases:
1. non-empty oplog, continue_on_error=True, invalid documents'

def test_dump_collection_with_error(self):

    self.opman.continue_on_error = True
    self.opman.oplog = self.primary_conn['local']['oplog.rs']
    docs = [{'a': i} for i in range(100)]
    for i in range(50, 60):
        docs[i]['_upsert_exception'] = True
    self.primary_conn['test']['test'].insert_many(docs)
    last_ts = self.opman.get_last_oplog_timestamp()
    self.assertEqual(last_ts, self.opman.dump_collection())
    docs = self.opman.doc_managers[0]._search()
    docs.sort(key=(lambda doc: doc['a']))
    self.assertEqual(len(docs), 90)
    expected_a = itertools.chain(range(0, 50), range(60, 100))
    for (doc, correct_a) in zip(docs, expected_a):
        self.assertEqual(doc['a'], correct_a)
