# 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

        red0_blue1 = BigCharListModel.objects.filter(field__0="red", field__1="blue")
        assert list(red0_blue1) == [mymodel]

        red0_or_blue0 = BigCharListModel.objects.filter(
            Q(field__0="red") | Q(field__0="blue")
        )
        assert list(red0_or_blue0) == [mymodel]

    def test_int_easy(self):
        mymodel = BigIntListModel.objects.create(field=[1, 2])
        assert mymodel.field == [1, 2]
        mymodel = BigIntListModel.objects.get(id=mymodel.id)
        assert mymodel.field == [1, 2]

    def test_int_contains_lookup(self):
        onetwo = BigIntListModel.objects.create(field=[1, 2])

        ones = BigIntListModel.objects.filter(field__contains=1)
        assert ones.count() == 1
        assert ones[0] == onetwo

        twos = BigIntListModel.objects.filter(field__contains=2)
        assert twos.count() == 1
        assert twos[0] == onetwo

        threes = BigIntListModel.objects.filter(field__contains=3)
        assert threes.count() == 0

        with pytest.raises(ValueError):

# 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


        red0_blue1 = BigCharListModel.objects.filter(field__0="red", field__1="blue")
        assert list(red0_blue1) == [mymodel]

        red0_or_blue0 = BigCharListModel.objects.filter(
            Q(field__0="red") | Q(field__0="blue")
        )
        assert list(red0_or_blue0) == [mymodel]

    def test_int_easy(self):
        mymodel = BigIntListModel.objects.create(field=[1, 2])
        assert mymodel.field == [1, 2]
        mymodel = BigIntListModel.objects.get(id=mymodel.id)
        assert mymodel.field == [1, 2]

    def test_int_contains_lookup(self):
        onetwo = BigIntListModel.objects.create(field=[1, 2])

        ones = BigIntListModel.objects.filter(field__contains=1)
        assert ones.count() == 1
        assert ones[0] == onetwo

        twos = BigIntListModel.objects.filter(field__contains=2)
        assert twos.count() == 1
        assert twos[0] == onetwo

        threes = BigIntListModel.objects.filter(field__contains=3)
        assert threes.count() == 0

        with pytest.raises(ValueError):

            list(BigIntListModel.objects.filter(field__contains=[1, 2]))