'Verify that the last ReportStore CSV contains the expected content.
Arguments:
expected_rows (iterable): An iterable of dictionaries,
where each dict represents a row of data in the last
ReportStore CSV.  Each dict maps keys from the CSV
header to values in that row\'s corresponding cell.
file_index (int): Describes which report store file to
open.  Files are ordered by last modified date, and 0
corresponds to the most recently modified file.
verify_order (boolean): When True (default), we verify that
both the content and order of `expected_rows` matches
the actual csv rows.  When False, we only verify that
the content matches.
ignore_other_columns (boolean): When True, we verify that `expected_rows`
contain data which is the subset of actual csv rows.'

def verify_rows_in_csv(self, expected_rows, file_index=0, verify_order=True, ignore_other_columns=False):

    report_store = ReportStore.from_config(config_name='GRADES_DOWNLOAD')
    report_csv_filename = report_store.links_for(self.course.id)[file_index][0]
    report_path = report_store.path_to(self.course.id, report_csv_filename)
    with report_store.storage.open(report_path) as csv_file:
        csv_rows = [row for row in unicodecsv.DictReader(csv_file)]
        if ignore_other_columns:
            csv_rows = [{key: row.get(key) for key in expected_rows[index].keys()} for (index, row) in enumerate(csv_rows)]
        if verify_order:
            self.assertEqual(csv_rows, expected_rows)
        else:
            self.assertItemsEqual(csv_rows, expected_rows)
