def test_filter_no_value(self): instance = MultiFieldFilter(['username']) user_qs = User.objects.all() assert instance.filter(user_qs, '') == user_qs
def test_filter(self): instance = MultiFieldFilter(['username', '=first_name']) assert instance.filter( User.objects.all(), self.users[0].username).get() == self.users[0] assert instance.filter( User.objects.all(), self.users[1].first_name).get() == self.users[1]
def test_filter_no_fields(self): instance = MultiFieldFilter([]) user_qs = User.objects.all() assert instance.filter(user_qs, 'Foo') == user_qs
def test_filter(self): instance = MultiFieldFilter(['username', '=first_name']) assert instance.filter(User.objects.all(), self.users[0].username).get() == self.users[0] assert instance.filter(User.objects.all(), self.users[1].first_name).get() == self.users[1]
def test_init(self): instance = MultiFieldFilter(['username']) assert instance.fields == ['username']