def test_sort_by_readable(self):
        """
        Must generate correct data by most readable books for anonymous users and users with private books.
        Testing count of sorted books with and without selected categories.
        """
        sorted_structure = Book.sort_by_readable(self.anonymous_user, self.category1)
        self.assertTrue(isinstance(sorted_structure, list))
        self.assertTrue(isinstance(sorted_structure[0], dict))
        self.assertEqual(set(sorted_structure[0].keys()), {'id', 'name', 'author', 'url'})

        self.assertEqual(len(Book.sort_by_readable(user=self.anonymous_user, category=self.category1)), 3)
        self.assertEqual(len(Book.sort_by_readable(user=self.anonymous_user, category=self.category1, count=2)), 2)
        self.assertEqual(len(Book.sort_by_readable(user=self.the_user1.id_user, category=self.category1)), 3)
        self.assertEqual(len(Book.sort_by_readable(user=self.the_user1.id_user, category=self.category1, count=2)), 2)
        self.assertEqual(len(Book.sort_by_readable(user=self.the_user2.id_user, category=self.category1)), 3)
        self.assertEqual(len(Book.sort_by_readable(user=self.the_user2.id_user, category=self.category1, count=2)), 2)

        self.assertEqual(len(Book.sort_by_readable(user=self.anonymous_user)), 4)
        self.assertEqual(len(Book.sort_by_readable(user=self.anonymous_user, count=2)), 2)
        self.assertEqual(len(Book.sort_by_readable(user=self.the_user1.id_user)), 4)
        self.assertEqual(len(Book.sort_by_readable(user=self.the_user1.id_user, count=3)), 3)
        self.assertEqual(len(Book.sort_by_readable(user=self.the_user2.id_user)), 4)
        self.assertEqual(len(Book.sort_by_readable(user=self.the_user2.id_user, count=2)), 2)