3 Commits a12105558e ... 5362f7b4c6

Author SHA1 Message Date
  Mattias Jakobsson 5362f7b4c6 Added test case with model containing all non-postgres fields 6 years ago
  Mattias Jakobsson 4ef6cef786 Made black & flake8 ignore migrations when run by pre-commit 6 years ago
  Mattias Jakobsson 12a056bee8 Added a pyproject.toml with a black configuration 6 years ago

+ 2 - 0
.pre-commit-config.yaml

@@ -3,6 +3,7 @@ repos:
     rev: stable
     hooks:
       - id: black
+        exclude: tests/testapp/migrations
   - repo: https://github.com/pre-commit/pre-commit-hooks
     rev: v1.4.0
     hooks:
@@ -11,6 +12,7 @@ repos:
       - id: end-of-file-fixer
       - id: flake8
         language_version: python2.7
+        exclude: tests/testapp/migrations
       - id: trailing-whitespace
   - repo: https://notabug.org/mjakob/pre-commit-check-manifest
     rev: v0.1.0

+ 1 - 0
MANIFEST.in

@@ -1,5 +1,6 @@
 include LICENSE
 include .pre-commit-config.yaml
+include pyproject.toml
 include requirements.txt
 include tox.ini
 recursive-include tests *.py

+ 11 - 0
pyproject.toml

@@ -0,0 +1,11 @@
+[tool.black]
+exclude = '''
+/(
+    \.git
+  | \.pytest_cache
+  | .*\.egg-info
+  | tests/testapp/migrations
+  | \.tox
+  | \.venv
+/)
+'''

+ 2 - 1
requirements.txt

@@ -1,5 +1,5 @@
 # Install requirements
-Django
+django
 pytest-django
 six
 
@@ -8,6 +8,7 @@ black
 check-manifest
 flake8
 jedi
+pillow
 pre-commit
 psycopg2-binary
 pytest-cov

+ 1 - 0
tests/conftest.py

@@ -17,6 +17,7 @@ def pytest_configure():
             "django.contrib.contenttypes",
             "testapp",
         ],
+        USE_TZ=True,
     )
 
 

+ 0 - 2
tests/djangosettings.py

@@ -13,8 +13,6 @@ SECRET_KEY = "0ay!$_8q2x7fo1bza(@1ovtudbu&1x=!7tzqa#a$cc8x@4o0m3"
 
 INSTALLED_APPS = ["django.contrib.auth", "django.contrib.contenttypes", "testapp"]
 
-# ROOT_URLCONF = 'djangoproject.urls'
-
 DATABASES = {
     "default": {
         "ENGINE": "django.db.backends.sqlite3",

+ 6 - 0
tests/test_ifactory.py

@@ -9,6 +9,12 @@ import six
 from testapp.models import ModelA, ModelB
 
 
+def test_all_fields(ifactory):
+    instance = ifactory.testapp.allfieldsmodel()
+    for field in instance._meta.get_fields():
+        assert getattr(instance, field.name) is not None
+
+
 def test_initialization(ifactory):
     assert hasattr(ifactory, "testapp")
     assert hasattr(ifactory.testapp, "modela")

+ 36 - 52
tests/testapp/migrations/0001_initial.py

@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
-# Generated by Django 1.11.13 on 2018-05-25 06:22
-from __future__ import unicode_literals
+# Generated by Django 2.1 on 2018-08-24 01:33
 
 from django.db import migrations, models
 import django.db.models.deletion
@@ -10,63 +8,49 @@ class Migration(migrations.Migration):
 
     initial = True
 
-    dependencies = []
+    dependencies = [
+    ]
 
     operations = [
         migrations.CreateModel(
-            name="ModelA",
+            name='AllFieldsModel',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('boolean', models.BooleanField()),
+                ('char', models.CharField(max_length=32)),
+                ('file', models.FileField(upload_to='')),
+                ('image', models.ImageField(upload_to='')),
+                ('slug', models.SlugField()),
+                ('text', models.TextField()),
+                ('date', models.DateField()),
+                ('datetime', models.DateTimeField()),
+                ('float', models.FloatField()),
+                ('biginteger', models.BigIntegerField()),
+                ('decimal', models.DecimalField(decimal_places=0, max_digits=9)),
+                ('integer', models.IntegerField()),
+                ('positiveinteger', models.PositiveIntegerField()),
+                ('positivesmallinteger', models.PositiveSmallIntegerField()),
+                ('smallinteger', models.SmallIntegerField()),
+                ('time', models.TimeField()),
+            ],
+        ),
+        migrations.CreateModel(
+            name='ModelA',
             fields=[
-                (
-                    "id",
-                    models.AutoField(
-                        auto_created=True,
-                        primary_key=True,
-                        serialize=False,
-                        verbose_name="ID",
-                    ),
-                ),
-                ("name", models.CharField(max_length=64, unique=True)),
-                ("category", models.CharField(max_length=64)),
-                ("blank", models.CharField(blank=True, max_length=64)),
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('name', models.CharField(max_length=64, unique=True)),
+                ('category', models.CharField(max_length=64)),
+                ('blank', models.CharField(blank=True, max_length=64)),
             ],
         ),
         migrations.CreateModel(
-            name="ModelB",
+            name='ModelB',
             fields=[
-                (
-                    "id",
-                    models.AutoField(
-                        auto_created=True,
-                        primary_key=True,
-                        serialize=False,
-                        verbose_name="ID",
-                    ),
-                ),
-                ("name", models.CharField(max_length=64, unique=True)),
-                (
-                    "nullable_a1",
-                    models.ForeignKey(
-                        null=True,
-                        on_delete=django.db.models.deletion.CASCADE,
-                        related_name="+",
-                        to="testapp.ModelA",
-                    ),
-                ),
-                (
-                    "nullable_a2",
-                    models.ForeignKey(
-                        null=True,
-                        on_delete=django.db.models.deletion.CASCADE,
-                        related_name="+",
-                        to="testapp.ModelA",
-                    ),
-                ),
-                (
-                    "required_a",
-                    models.ForeignKey(
-                        on_delete=django.db.models.deletion.CASCADE, to="testapp.ModelA"
-                    ),
-                ),
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('name', models.CharField(max_length=64, unique=True)),
+                ('nullable_a1', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='testapp.ModelA')),
+                ('nullable_a2', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='testapp.ModelA')),
+                ('required_a', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='testapp.ModelA')),
             ],
         ),
     ]

+ 19 - 2
tests/testapp/models.py

@@ -6,14 +6,12 @@ from django.db import models
 
 
 class ModelA(models.Model):
-
     name = models.CharField(max_length=64, unique=True)
     category = models.CharField(max_length=64)
     blank = models.CharField(max_length=64, blank=True)
 
 
 class ModelB(models.Model):
-
     name = models.CharField(max_length=64, unique=True)
     required_a = models.ForeignKey(ModelA, on_delete=models.CASCADE)
     nullable_a1 = models.ForeignKey(
@@ -22,3 +20,22 @@ class ModelB(models.Model):
     nullable_a2 = models.ForeignKey(
         ModelA, on_delete=models.CASCADE, null=True, related_name="+"
     )
+
+
+class AllFieldsModel(models.Model):
+    boolean = models.BooleanField()
+    char = models.CharField(max_length=32)
+    file = models.FileField()
+    image = models.ImageField()
+    slug = models.SlugField()
+    text = models.TextField()
+    date = models.DateField()
+    datetime = models.DateTimeField()
+    float = models.FloatField()
+    biginteger = models.BigIntegerField()
+    decimal = models.DecimalField(decimal_places=0, max_digits=9)
+    integer = models.IntegerField()
+    positiveinteger = models.PositiveIntegerField()
+    positivesmallinteger = models.PositiveSmallIntegerField()
+    smallinteger = models.SmallIntegerField()
+    time = models.TimeField()

+ 0 - 0
tox.ini


Some files were not shown because too many files changed in this diff