Пример #1
0
 def test_get_csv(self):
     with StringIO() as read_buf:
         csv.load_team_membership_csv(self.course, read_buf)
         read_buf.seek(0)
         reader = DictReader(read_buf)
         team_memberships = list(reader)
     self._assert_test_users_on_team(team_memberships)
Пример #2
0
 def test_load_team_membership_csv(self):
     expected_csv_output = ('user,mode,teamset_1,teamset_2,teamset_3,teamset_4\r\n'
                            'user1,audit,team_1_1,team_2_2,team_3_1,\r\n'
                            'user2,verified,team_1_1,team_2_2,team_3_1,\r\n'
                            'user3,honors,,team_2_1,team_3_1,\r\n'
                            'user4,masters,,,team_3_2,\r\n'
                            'user5,masters,,,,\r\n')
     csv.load_team_membership_csv(self.course, self.buf)
     self.assertEqual(expected_csv_output, self.buf.getvalue())
Пример #3
0
def csv_export(course):
    """
    Call csv.load_team_membership_csv for the given course, and return the result.
    The result is returned in the form of a dictionary keyed by the 'user' identifiers for each row,
    mapping to the full parsed dictionary for that row of the csv.

    Returns: DictReader for the returned csv file
    """
    with StringIO() as read_buf:
        csv.load_team_membership_csv(course, read_buf)
        read_buf.seek(0)
        return DictReader(read_buf.readlines())