How to write an integration test of the following list view in django? I need an example.
class HomeView(ListView):
model = Donor
template_name = 'recipient/home.html'
context_object_name = 'donors'
paginate_by = 10
def get_queryset(self):
form = self.request.GET.get('q')
if form:
return Donor.objects.filter(
Q(name__icontains=form) |
Q(location__icontains=form) |
Q(sex__icontains=form) |
Q(age__icontains=form) |
Q(blood_group__icontains=form)
).order_by('id')
queryset = Donor.objects.all().order_by('id')
return queryset
def get_context_data(self, **kwargs):
kwargs['q'] = self.request.GET.get('q')
return super().get_context_data(**kwargs)