def test_response(self, mock_call): data = convert_list_of_dicts_to_csv(mock_call(self.course_id)) mock_call.return_value = data response = self.client.get(self.path) # Check content type self.assertResponseContentType(response, 'text/csv') # Check filename filename = '{0}_{1}.csv'.format(self.course_id, self.base_file_name) self.assertResponseFilename(response, filename) # Check data self.assertEqual(response.content, data)
def test_response_no_data(self, mock_call): # Create an "empty" CSV that only has headers data = convert_list_of_dicts_to_csv([], self.column_headings) mock_call.return_value = data self.client.login(username=self.user.username, password=self.PASSWORD) response = self.client.get(self.path) # Check content type self.assertResponseContentType(response, 'text/csv') # Check filename filename = '{0}_{1}.csv'.format(self.course_id, self.base_file_name) self.assertResponseFilename(response, filename) # Check data self.assertEqual(response.content, data)
def test_response(self, course_id): csv_data = self.get_mock_data(course_id) csv_data = convert_list_of_dicts_to_csv(csv_data) self._test_csv(course_id, csv_data)
def test_response_no_data(self, course_id): # Create an "empty" CSV that only has headers csv_data = convert_list_of_dicts_to_csv([], self.column_headings) self._test_csv(course_id, csv_data)