Example #1
0
class SizeFieldModel(Model):
    binary1 = SizedBinaryField(size_class=1)
    binary2 = SizedBinaryField(size_class=2)
    binary3 = SizedBinaryField(size_class=3)
    binary4 = SizedBinaryField(size_class=4)
    text1 = SizedTextField(size_class=1)
    text2 = SizedTextField(size_class=2)
    text3 = SizedTextField(size_class=3)
    text4 = SizedTextField(size_class=4)
    def test_makemigrations_size_class_implicit(self):
        field = SizedBinaryField()
        statement, imports = MigrationWriter.serialize(field)

        assert (
            statement ==
            "django_mysql.models.SizedBinaryField(size_class=4)"
        )
Example #3
0
class Uploader(models.Model):
    IDS = models.CharField(max_length=20)
    EMAIL = models.CharField(max_length=50)
    PHONE = models.CharField(max_length=15)
    FILENAME = models.CharField(max_length=50)
    FILE = SizedBinaryField(3)
    STATUS = models.CharField(default='SUBMITTED', max_length=15)
    CLOSEDON = models.DateTimeField(default=None, blank=True, null=True)
    objects = UserManager()
class Migration(migrations.Migration):

    dependencies = [
        ('testapp', '0001_initial'),
    ]

    operations = [
        migrations.AlterField(model_name='sizedbinaryaltermodel',
                              name='field',
                              field=SizedBinaryField(size_class=2)),
    ]
class Migration(migrations.Migration):

    dependencies = [("testapp", "0001_initial")]

    operations = [
        migrations.AlterField(
            model_name="sizedbinaryaltermodel",
            name="field",
            field=SizedBinaryField(size_class=2),
        )
    ]
Example #6
0
class Migration(migrations.Migration):

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='SizedBinaryAlterModel',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('field', SizedBinaryField(size_class=4)),
            ],
            options={},
            bases=(models.Model, ),
        ),
    ]
Example #7
0
class Migration(migrations.Migration):

    dependencies: list[tuple[str, str]] = []

    operations = [
        migrations.CreateModel(
            name="SizedBinaryAlterModel",
            fields=[
                (
                    "id",
                    models.AutoField(
                        verbose_name="ID",
                        serialize=False,
                        auto_created=True,
                        primary_key=True,
                    ),
                ),
                ("field", SizedBinaryField(size_class=4)),
            ],
            options={},
            bases=(models.Model, ),
        )
    ]
 def test_deconstruct_size_class_2(self):
     field = SizedBinaryField(size_class=2)
     name, path, args, kwargs = field.deconstruct()
     new = SizedBinaryField(*args, **kwargs)
     assert new.size_class == field.size_class
 def test_deconstruct_path(self):
     field = SizedBinaryField(size_class=1)
     name, path, args, kwargs = field.deconstruct()
     assert path == 'django_mysql.models.SizedBinaryField'
 def test_binaryfield_default_length(self):
     # By default, SizedBinaryField should act like BinaryField
     field = SizedBinaryField()
     assert field.size_class == 4
     assert field.db_type(None) == 'longblob'
 class InvalidSizedBinaryModel(TemporaryModel):
     field = SizedBinaryField(size_class=5)
Example #12
0
 def test_deconstruct_size_class_2(self):
     field = SizedBinaryField(size_class=2)
     name, path, args, kwargs = field.deconstruct()
     new = SizedBinaryField(*args, **kwargs)
     assert new.size_class == field.size_class
Example #13
0
 def test_deconstruct_path(self):
     field = SizedBinaryField(size_class=1)
     name, path, args, kwargs = field.deconstruct()
     assert path == "django_mysql.models.SizedBinaryField"
Example #14
0
 def test_binaryfield_default_length(self):
     # By default, SizedBinaryField should act like BinaryField
     field = SizedBinaryField()
     assert field.size_class == 4
     assert field.db_type(None) == "longblob"
 class Invalid(models.Model):
     field = SizedBinaryField(size_class=5)