'Test the get_oplog_cursor method'

def test_get_oplog_cursor(self):

    cursor = self.opman.get_oplog_cursor(None)
    self.assertEqual(cursor.count(), self.primary_conn['local']['oplog.rs'].find({'op': {'$ne': 'n'}}).count())
    doc = {'ts': bson.Timestamp(1000, 0), 'i': 1}
    self.primary_conn['test']['test'].insert_one(doc)
    latest_timestamp = self.opman.get_last_oplog_timestamp()
    cursor = self.opman.get_oplog_cursor(latest_timestamp)
    self.assertNotEqual(cursor, None)
    self.assertEqual(cursor.count(), 1)
    next_entry_id = next(cursor)['o']['_id']
    retrieved = self.primary_conn.test.test.find_one(next_entry_id)
    self.assertEqual(retrieved, doc)
    self.primary_conn['test']['test'].insert_many([{'i': i} for i in range(2, 1002)])
    oplog_cursor = self.oplog_coll.find({'op': {'$ne': 'n'}, 'ns': {'$not': re.compile('\\.(system|\\$cmd)')}}, sort=[('ts', pymongo.ASCENDING)])
    self.assertEqual(oplog_cursor.count(), (1 + 1000))
    pivot = oplog_cursor.skip(400).limit((-1))[0]
    goc_cursor = self.opman.get_oplog_cursor(pivot['ts'])
    self.assertEqual(goc_cursor.count(), ((1 + 1000) - 400))
