title: Django REST framework. APITestCase. How test views which response for download data to csv
body: <p>I have views like:</p>
  
  <pre><code>class StudentAPIPerformanceReport(
      generics.RetrieveAPIView,
  ):
      def get(self, request, *args, **kwargs):
          response = HttpResponse(content_type='text/csv')
          response['Content-Disposition'] = 'attachment; filename="report.csv"'
  
          writer = csv.writer(response)
          for student in Student.objects.filter(pk=self.kwargs['pk']):
              assigned_courses = CourseParticipant.objects.filter(student=student)
              completed_courses = assigned_courses.filter(completed=True)
  
              headings = (
                  "student full Name",
                  "number of assigned courses to student",
                  "number of completed courses by student"
              )
              rows = (
                  student.full_name,
                  assigned_courses.count(),
                  completed_courses.count()
              )
  
              writer.writerow(headings)
              writer.writerow(rows)
  
          return response
  </code></pre>
  
  <p>Urls:</p>
  
  <pre><code>    path(
      'student/report/&lt;int:pk&gt;/',
      StudentAPIPerformanceReport.as_view(),
      name='student_performance'
  )
  </code></pre>
  
  <p>And test for it view:</p>
  
  <pre><code>class StudentAPIPerformanceReportTestCase(APITestCase):
  def setUp(self):
      self.student_obj = Student.objects.create(
          first_name='test',
          last_name='student',
          email='test_student@gmail.com',
      )
      self.course_obj = Course.objects.create(
          name='test',
      )
      student_obj = CourseParticipant.objects.create(
          course_id=self.course_obj.pk,
          student_id=self.student_obj.pk,
      )
  
  def test_student_unassigned_from_course(self):
      data_id = self.student_obj.pk
      rud_url = api_reverse('student:student_performance', kwargs={'pk': data_id})
  
      get_response = self.client.get(rud_url, data_id)
      self.assertEqual(get_response.status_code, status.HTTP_200_OK)
  </code></pre>
  
  <p>But i have Traceback:</p>
  
  <blockquote>
    <p>Error
    Traceback (most recent call last):
      File "/home/project/test_task/student/tests.py", line 120, in test_student_unassigned_from_course
        get_response = self.client.get(rud_url, data_id)
      File "/home/project/test_task/venv/lib/python3.7/site-packages/rest_framework/test.py", line 292, in get
        response = super(APIClient, self).get(path, data=data, **extra)
      File "/home/project/test_task/venv/lib/python3.7/site-packages/rest_framework/test.py", line 199, in get
        'QUERY_STRING': urlencode(data or {}, doseq=True),
      File "/home/project/test_task/venv/lib/python3.7/site-packages/django/utils/http.py", line 93, in urlencode
        for key, value in query:
    TypeError: 'int' object is not iterable</p>
  </blockquote>
  
  <p>Api which i wont to test just make some csv file in format:</p>
  
  <pre><code>test student,1,0
  </code></pre>
  
  <p>How i can test it? I will be grateful for the help</p>