"""This module holds the tests for the serializers of the ``brainstormers`` app"""

from mtp.apps.brainstormers.tests.test_cases import BrainstormerTestCase
from mtp.apps.brainstormers.factories import BrainstormerPropositionFactory

from ..serializers import BrainstormerPropositionGroupSerializer


class BrainstormerPropositionGroupSerializerTestCase(BrainstormerTestCase):
    """Test cases for the ``BrainstormerPropositionGroupSerializer`` serializer"""

    @classmethod
    def setUpTestData(cls):
        """Set up the test data"""

        super().setUpTestData()

        # We will need sample data to serialize
        cls.brainstormer_proposition_groups = {
            'brainstormer': cls.brainstormer.pk,
            'propositions': [
                {
                    'group': group.pk
                }
                for group in BrainstormerPropositionFactory.create_batch(3)
            ],
            'order': 0,
            'x': 10.10,
            'y': 11.10
        }

    def test_serializer_with_valid_data(self):
        """test the serializer with valid data"""

        serialized = BrainstormerPropositionGroupSerializer(
            data=self.brainstormer_proposition_groups)

        self.assertTrue(serialized.is_valid())
