def test_status_serializer_method_field(self):
        """Ensure that the project `status` serializer method field has the correct value in an API response.
        """
        url = reverse('project-list')

        response = self.client.get(f'{url}/{self.project.pk}/')
        self.assertEqual(
            Project.ProjectStatus(self.project.status).label,
            response.data['status'])
Exemple #2
0
    def get_status(self, obj):
        """A get method for the ProjectSerializer class' ``status`` attribute.

        Args:
            obj: The Project object that is being serialized.

        Returns:
            The verbose label associated with the ``status`` of the Project object.
        """
        return Project.ProjectStatus(obj.status).label