from django.test import TestCase

from vbv_lernwelt.core.tests.factories import UserFactory
from vbv_lernwelt.simpletodo.models import SimpleTask
from vbv_lernwelt.simpletodo.serializers import SimpleTaskSerializer


class SimpleTaskSerializerTestCase(TestCase):
    def setUp(self) -> None:
        self.user = UserFactory()

    def test_serializer(self):
        serializer = SimpleTaskSerializer(
            data={
                "title": "Test",
                "list_title": "Todos",
            }
        )

        serializer.is_valid(raise_exception=True)
        serializer.save(user=self.user)

        task = SimpleTask.objects.first()

        self.assertEqual(task.title, "Test")
        self.assertEqual(task.list.title, "Todos")
