# Path: tests/testapp/models.py
# class BigCharListModel(Model):
#     field = ListTextField(base_field=CharField(max_length=8))
# 
# class BigIntListModel(Model):
#     field = ListTextField(base_field=IntegerField())


import json
import re
import pytest
from django import forms
from django.core import exceptions, serializers
from django.db import models
from django.db.migrations.writer import MigrationWriter
from django.db.models import Q
from django.test import SimpleTestCase, TestCase
from django.test.utils import isolate_apps
from django_mysql.forms import SimpleListField
from django_mysql.models import ListTextField
from tests.testapp.models import BigCharListModel, BigIntListModel
        from django_mysql.models.fields import ListTextField as LTField
        from django_mysql.models.fields.lists import ListTextField as LTField
from __future__ import annotations





class TestSaveLoad(TestCase):
    def test_char_easy(self):
        s = BigCharListModel.objects.create(field=["comfy", "big"])
        assert s.field == ["comfy", "big"]
        s = BigCharListModel.objects.get(id=s.id)
        assert s.field == ["comfy", "big"]

        s.field.append("round")
        s.save()
        assert s.field == ["comfy", "big", "round"]
        s = BigCharListModel.objects.get(id=s.id)
        assert s.field == ["comfy", "big", "round"]

    def test_char_string_direct(self):
        s = BigCharListModel.objects.create(field="big,bad")
        s = BigCharListModel.objects.get(id=s.id)
        assert s.field == ["big", "bad"]

    def test_is_a_list_immediately(self):
        s = BigCharListModel()
        assert s.field == []
        s.field.append("bold")

# Path: tests/testapp/models.py
# class BigCharListModel(Model):
#     field = ListTextField(base_field=CharField(max_length=8))
# 
# class BigIntListModel(Model):
#     field = ListTextField(base_field=IntegerField())


# Path: tests/testapp/test_listtextfield.py
import json
import re
import pytest
from django import forms
from django.core import exceptions, serializers
from django.db import models
from django.db.migrations.writer import MigrationWriter
from django.db.models import Q
from django.test import SimpleTestCase, TestCase
from django.test.utils import isolate_apps
from django_mysql.forms import SimpleListField
from django_mysql.models import ListTextField
from tests.testapp.models import BigCharListModel, BigIntListModel
        from django_mysql.models.fields import ListTextField as LTField
        from django_mysql.models.fields.lists import ListTextField as LTField

from __future__ import annotations





class TestSaveLoad(TestCase):
    def test_char_easy(self):
        s = BigCharListModel.objects.create(field=["comfy", "big"])
        assert s.field == ["comfy", "big"]
        s = BigCharListModel.objects.get(id=s.id)
        assert s.field == ["comfy", "big"]

        s.field.append("round")
        s.save()
        assert s.field == ["comfy", "big", "round"]
        s = BigCharListModel.objects.get(id=s.id)
        assert s.field == ["comfy", "big", "round"]

    def test_char_string_direct(self):
        s = BigCharListModel.objects.create(field="big,bad")
        s = BigCharListModel.objects.get(id=s.id)
        assert s.field == ["big", "bad"]

    def test_is_a_list_immediately(self):
        s = BigCharListModel()
        assert s.field == []
        s.field.append("bold")

        s.field.append("brave")