'Helper method to verify cohort assignments after a successful CSV upload.
When skip_events is specified, no assertions are made on events.'

def _verify_csv_upload_acceptable_file(self, filename, skip_events=None):

    start_time = datetime.now(UTC)
    self.cohort_management_page.upload_cohort_file(filename)
    self._verify_cohort_by_csv_notification("Your    file    '{}'    has    been    uploaded.    Allow    a    few    minutes    for    processing.".format(filename))
    if (not skip_events):
        self.assertEqual(self.event_collection.find({'name': 'edx.cohort.user_added', 'time': {'$gt': start_time}, 'event.user_id': {'$in': [int(self.student_id)]}, 'event.cohort_name': self.auto_cohort_name}).count(), 1)
        self.assertEqual(self.event_collection.find({'name': 'edx.cohort.user_removed', 'time': {'$gt': start_time}, 'event.user_id': int(self.student_id), 'event.cohort_name': self.manual_cohort_name}).count(), 1)
        self.assertEqual(self.event_collection.find({'name': 'edx.cohort.user_added', 'time': {'$gt': start_time}, 'event.user_id': {'$in': [int(self.instructor_id)]}, 'event.cohort_name': self.manual_cohort_name}).count(), 1)
        self.assertEqual(self.event_collection.find({'name': 'edx.cohort.user_added', 'time': {'$gt': start_time}, 'event.user_id': {'$in': [int(self.other_student_id)]}, 'event.cohort_name': self.manual_cohort_name}).count(), 1)
    data_download = self.instructor_dashboard_page.select_data_download()
    data_download.wait_for_available_report()
    report = data_download.get_available_reports_for_download()[0]
    base_file_name = 'cohort_results_'
    self.assertIn('{}_{}'.format('_'.join([self.course_info['org'], self.course_info['number'], self.course_info['run']]), base_file_name), report)
    report_datetime = datetime.strptime(report[(report.index(base_file_name) + len(base_file_name)):(- len('.csv'))], '%Y-%m-%d-%H%M')
    self.assertLessEqual(start_time.replace(second=0, microsecond=0), utc.localize(report_datetime))
