old_contents: from rest_framework import status
  from rest_framework.test import APITestCase
  from foodsaving.groups.factories import GroupFactory
  from foodsaving.users.factories import UserFactory
  
  
  class TestStoresAPIFilter(APITestCase):
      @classmethod
      def setUpClass(cls):
          super().setUpClass()
          cls.url = '/api/groups/'
  
          # some user
          cls.user = UserFactory()
  
          # two groups with different members
          cls.member = UserFactory()
          cls.group = GroupFactory(members=[cls.member, ])
          cls.member2 = UserFactory()
          cls.group2 = GroupFactory(members=[cls.member2, ])
          cls.empty_group = GroupFactory()
  
      def test_filter_by_member(self):
          response = self.client.get(self.url, {'members': self.member.id})
          self.assertEqual(response.status_code, status.HTTP_200_OK)
          self.assertEqual(len(response.data), 1)
          self.assertEqual(response.data[0]['name'], self.group.name)
  
          response = self.client.get(self.url, {'members': self.member.id})
          self.assertEqual(response.status_code, status.HTTP_200_OK)
          self.assertEqual(len(response.data), 1)
          self.assertEqual(response.data[0]['name'], self.group.name)
  
      def test_dont_include_empty(self):
          response = self.client.get(self.url, {'include_empty': False})
          self.assertEqual(response.status_code, status.HTTP_200_OK)
          self.assertEqual(len(response.data), 2)
          self.assertFalse(self.empty_group.id in [_['id'] for _ in response.data])
  
      def test_include_empty(self):
          response = self.client.get(self.url, {'include_empty': True})
          self.assertEqual(response.status_code, status.HTTP_200_OK)
          self.assertEqual(len(response.data), 3)
  
      def test_search_name(self):
          response = self.client.get(self.url, {'search': self.group.name})
          self.assertEqual(response.status_code, status.HTTP_200_OK)
          self.assertEqual(len(response.data), 1)
          self.assertEqual(response.data[0]['name'], self.group.name)
  
      def test_search_description(self):
          response = self.client.get(self.url, {'search': self.group.public_description[:10]})
          self.assertEqual(response.status_code, status.HTTP_200_OK)
          self.assertEqual(len(response.data), 1)
          self.assertEqual(response.data[0]['name'], self.group.name)
  
new_contents: from rest_framework import status
  from rest_framework.test import APITestCase
  from foodsaving.groups.factories import GroupFactory
  from foodsaving.users.factories import UserFactory
  
  
  class TestGroupsAPIFilter(APITestCase):
      @classmethod
      def setUpClass(cls):
          super().setUpClass()
          cls.url = '/api/groups/'
  
          # some user
          cls.user = UserFactory()
  
          # two groups with different members
          cls.member = UserFactory()
          cls.group = GroupFactory(members=[cls.member, ])
          cls.member2 = UserFactory()
          cls.group2 = GroupFactory(members=[cls.member2, ])
          cls.empty_group = GroupFactory()
  
      def test_filter_by_member(self):
          response = self.client.get(self.url, {'members': self.member.id})
          self.assertEqual(response.status_code, status.HTTP_200_OK)
          self.assertEqual(len(response.data), 1)
          self.assertEqual(response.data[0]['name'], self.group.name)
  
          response = self.client.get(self.url, {'members': self.member.id})
          self.assertEqual(response.status_code, status.HTTP_200_OK)
          self.assertEqual(len(response.data), 1)
          self.assertEqual(response.data[0]['name'], self.group.name)
  
      def test_dont_include_empty(self):
          response = self.client.get(self.url, {'include_empty': False})
          self.assertEqual(response.status_code, status.HTTP_200_OK)
          self.assertEqual(len(response.data), 2)
          self.assertFalse(self.empty_group.id in [_['id'] for _ in response.data])
  
      def test_include_empty(self):
          response = self.client.get(self.url, {'include_empty': True})
          self.assertEqual(response.status_code, status.HTTP_200_OK)
          self.assertEqual(len(response.data), 3)
  
      def test_search_name(self):
          response = self.client.get(self.url, {'search': self.group.name})
          self.assertEqual(response.status_code, status.HTTP_200_OK)
          self.assertEqual(len(response.data), 1)
          self.assertEqual(response.data[0]['name'], self.group.name)
  
      def test_search_description(self):
          response = self.client.get(self.url, {'search': self.group.public_description})
          self.assertEqual(response.status_code, status.HTTP_200_OK)
          self.assertEqual(len(response.data), 1)
          self.assertEqual(response.data[0]['name'], self.group.name)
  
subject: use full search text to allow for low faker entropy