I am new to Django, so maybe this is very simple, but I have been trying to make sense of the documentation all day and I need some help, some way to going in the right direction. Basically, I have a Custom Filter class, like this
class CustomFilter(django_filters.rest_framework.FilterSet):
username = BooleanFilter(method='filter_current_user')
...
And inside, several methods, being the following the simpler of them
def filter_current_user(self, queryset, name, value):
if value is True:
return queryset.filter(user=self.request.user)
return queryset
How can I write a test that validates the differences of the queryset returned when value is True and when value is False?
My biggest problem is how make that the self value contains the request.user.