"""Test models specific stuff for the ``tasks`` app. """

from unittest import TestCase

from ..models import DjangoTask, TASK_STATES


class TasksModelVerySimpleTestCase(TestCase):
    """Very simple test case that don't need any access to database"""

    def test_max_state_length(self):
        """Test that the max length of the ``state`` field is enough to hold all states"""

        max_length = DjangoTask._meta.get_field('state').max_length

        overflow_states = [value for value in TASK_STATES.values if len(value) > max_length]

        if overflow_states:
            self.fail(
                'Some celery states %s are too long (> %d) to fit in the `state` field of the '
                '`DjangoTask` model' % (overflow_states, max_length)
            )
