From dd607e14daeecb2a36803262bedd7d31c4e3b4b4 Mon Sep 17 00:00:00 2001 From: Ray Logel Date: Tue, 28 Nov 2017 15:01:04 -0500 Subject: [PATCH 1/8] Issue #331: If foreign key is specified via _id don't create reference --- model_mommy/mommy.py | 3 ++- test/generic/tests/test_mommy.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/model_mommy/mommy.py b/model_mommy/mommy.py index a4f5236..96f1543 100644 --- a/model_mommy/mommy.py +++ b/model_mommy/mommy.py @@ -252,7 +252,8 @@ def _make(self, commit=True, commit_related=True, _save_kwargs=None, **attrs): else: self.m2m_dict[field.name] = self.model_attrs.pop(field.name) elif field.name not in self.model_attrs: - self.model_attrs[field.name] = self.generate_value(field, commit_related) + if not isinstance(field, ForeignKey) or '{0}_id'.format(field.name) not in self.model_attrs: + self.model_attrs[field.name] = self.generate_value(field, commit_related) elif callable(self.model_attrs[field.name]): self.model_attrs[field.name] = self.model_attrs[field.name]() elif field.name in self.iterator_attrs: diff --git a/test/generic/tests/test_mommy.py b/test/generic/tests/test_mommy.py index b939261..8a511fe 100644 --- a/test/generic/tests/test_mommy.py +++ b/test/generic/tests/test_mommy.py @@ -177,6 +177,26 @@ def test_foreign_key_on_parent_should_create_one_object(self): person_count = models.Person.objects.count() mommy.make(models.GuardDog) self.assertEqual(models.Person.objects.count(), person_count + 1) + + def test_foreign_key_on_parent_is_not_created(self): + ''' + Foreign key on parent doesn't get created using owner + ''' + owner = mommy.make(models.Person) + person_count = models.Person.objects.count() + dog = mommy.make(models.GuardDog, owner=owner) + self.assertEqual(models.Person.objects.count(), person_count) + self.assertEqual(dog.owner, owner) + + def test_foreign_key_on_parent_id_is_not_created(self): + ''' + Foreign key on parent doesn't get created using owner_id + ''' + owner = mommy.make(models.Person) + person_count = models.Person.objects.count() + dog = mommy.make(models.GuardDog, owner_id=owner.id) + self.assertEqual(models.Person.objects.count(), person_count) + self.assertEqual(models.GuardDog.objects.get(pk=dog.pk).owner, owner) def test_auto_now_add_on_parent_should_work(self): ''' From 6b983c74edbfbf67942c40a924a3930d0b0a4c84 Mon Sep 17 00:00:00 2001 From: Dylan Verheul Date: Tue, 2 Jan 2018 08:47:15 +0100 Subject: [PATCH 2/8] Support GIS fields when django.contrib.gis is in INSTALLED_APPS --- model_mommy/generators.py | 7 +- model_mommy/gis.py | 30 ++++++ model_mommy/random_gen.py | 107 +++++++++++++++++++++- runtests.py | 31 +++++-- test/generic/models.py | 34 +++++-- test/generic/tests/test_filling_fields.py | 49 ++++++++-- 6 files changed, 226 insertions(+), 32 deletions(-) create mode 100644 model_mommy/gis.py diff --git a/model_mommy/generators.py b/model_mommy/generators.py index f1fb0b3..1d74cc5 100644 --- a/model_mommy/generators.py +++ b/model_mommy/generators.py @@ -7,7 +7,8 @@ FloatField, FileField, ImageField, IPAddressField, ForeignKey, ManyToManyField, OneToOneField, NullBooleanField) -from model_mommy.utils import import_if_str +from .gis import default_gis_mapping +from .utils import import_if_str try: from django.db.models import BigIntegerField @@ -50,6 +51,7 @@ HStoreField = None from . import random_gen + default_mapping = { ForeignKey: random_gen.gen_related, OneToOneField: random_gen.gen_related, @@ -98,6 +100,9 @@ if HStoreField: default_mapping[HStoreField] = random_gen.gen_hstore +# Add GIS fields +default_mapping.update(default_gis_mapping) + def get_type_mapping(): mapping = default_mapping.copy() diff --git a/model_mommy/gis.py b/model_mommy/gis.py new file mode 100644 index 0000000..e3db053 --- /dev/null +++ b/model_mommy/gis.py @@ -0,0 +1,30 @@ +from __future__ import absolute_import +from django.apps import apps + +MOMMY_GIS = apps.is_installed("django.contrib.gis") + +default_gis_mapping = {} + +__all__ = ['MOMMY_GIS', 'default_gis_mapping'] + +if MOMMY_GIS: + from . import random_gen + from django.contrib.gis.db.models import ( + GeometryField, + PointField, + LineStringField, + PolygonField, + MultiPointField, + MultiLineStringField, + MultiPolygonField, + GeometryCollectionField, + ) + + default_gis_mapping[GeometryField] = random_gen.gen_geometry + default_gis_mapping[PointField] = random_gen.gen_point + default_gis_mapping[LineStringField] = random_gen.gen_line_string + default_gis_mapping[PolygonField] = random_gen.gen_polygon + default_gis_mapping[MultiPointField] = random_gen.gen_multi_point + default_gis_mapping[MultiLineStringField] = random_gen.gen_multi_line_string + default_gis_mapping[MultiPolygonField] = random_gen.gen_multi_polygon + default_gis_mapping[GeometryCollectionField] = random_gen.gen_geometry_collection diff --git a/model_mommy/random_gen.py b/model_mommy/random_gen.py index 8ba1a19..e4befba 100644 --- a/model_mommy/random_gen.py +++ b/model_mommy/random_gen.py @@ -14,10 +14,11 @@ import warnings from decimal import Decimal from os.path import abspath, join, dirname -from random import randint, choice, random -from django.core.files.base import ContentFile -from django.core.exceptions import ValidationError +from random import randint, choice, random, uniform + import six +from django.core.exceptions import ValidationError +from django.core.files.base import ContentFile from model_mommy.timezone import now @@ -27,21 +28,23 @@ except NameError: pass - MAX_LENGTH = 300 # Using sys.maxint here breaks a bunch of tests when running against a # Postgres database. MAX_INT = 10000 + def get_content_file(content, name): return ContentFile(content, name=name) + def gen_file_field(): name = 'mock_file.txt' file_path = abspath(join(dirname(__file__), name)) with open(file_path, 'rb') as f: return get_content_file(f.read(), name=name) + def gen_image_field(): name = 'mock-img.jpeg' file_path = abspath(join(dirname(__file__), name)) @@ -58,6 +61,7 @@ class KidMommy(Mommy): ''' return lambda: choice(list(L)) + # -- DEFAULT GENERATORS -- @@ -84,9 +88,10 @@ def gen_decimal(max_digits, decimal_places): num_as_str = lambda x: ''.join([str(randint(0, 9)) for i in range(x)]) if decimal_places: return Decimal("%s.%s" % (num_as_str(max_digits - decimal_places - 1), - num_as_str(decimal_places))) + num_as_str(decimal_places))) return Decimal(num_as_str(max_digits)) + gen_decimal.required = ['max_digits', 'decimal_places'] @@ -104,12 +109,16 @@ def gen_time(): def gen_string(max_length): return str(''.join(choice(string.ascii_letters) for i in range(max_length))) + + gen_string.required = ['max_length'] def gen_slug(max_length): valid_chars = string.ascii_letters + string.digits + '_-' return str(''.join(choice(valid_chars) for i in range(max_length))) + + gen_slug.required = ['max_length'] @@ -145,6 +154,7 @@ def gen_ipv46(): ip_gen = choice([gen_ipv4, gen_ipv6]) return ip_gen() + def gen_ip(protocol, default_validators): protocol = (protocol or '').lower() @@ -170,8 +180,11 @@ def gen_ip(protocol, default_validators): generator = gen_ipv46 return generator() + + gen_ip.required = ['protocol', 'default_validators'] + def gen_byte_string(max_length=16): generator = (randint(0, 255) for x in range(max_length)) if six.PY2: @@ -179,12 +192,14 @@ def gen_byte_string(max_length=16): elif six.PY3: return bytes(generator) + def gen_interval(interval_key='milliseconds'): from datetime import timedelta interval = gen_integer() kwargs = {interval_key: interval} return timedelta(**kwargs) + def gen_content_type(): from django.contrib.contenttypes.models import ContentType try: @@ -200,6 +215,7 @@ def gen_content_type(): warnings.warn('Database access disabled, returning ContentType raw instance') return ContentType() + def gen_uuid(): import uuid return uuid.uuid4() @@ -216,6 +232,7 @@ def gen_json(): def gen_hstore(): return {} + def _fk_model(field): try: return ('model', field.related_model) @@ -231,6 +248,8 @@ def _prepare_related(model, **attrs): def gen_related(model, **attrs): from .mommy import make return make(model, **attrs) + + gen_related.required = [_fk_model] gen_related.prepare = _prepare_related @@ -238,4 +257,82 @@ def gen_related(model, **attrs): def gen_m2m(model, **attrs): from .mommy import make, MAX_MANY_QUANTITY return make(model, _quantity=MAX_MANY_QUANTITY, **attrs) + + gen_m2m.required = [_fk_model] + + +# GIS generators + +def gen_coord(): + return uniform(0, 1) + + +def gen_coords(): + return '{x} {y}'.format(x=gen_coord(), y=gen_coord()) + + +def gen_point(): + return 'POINT ({})'.format( + gen_coords(), + ) + + +def _gen_line_string_without_prefix(): + return '({}, {})'.format( + gen_coords(), + gen_coords(), + ) + + +def gen_line_string(): + return 'LINESTRING {}'.format( + _gen_line_string_without_prefix() + ) + + +def _gen_polygon_without_prefix(): + start = gen_coords() + return '(({}, {}, {}, {}))'.format( + start, + gen_coords(), + gen_coords(), + start + ) + + +def gen_polygon(): + return 'POLYGON {}'.format( + _gen_polygon_without_prefix(), + ) + + +def gen_multi_point(): + return 'MULTIPOINT (({}), ({}))'.format( + gen_coords(), + gen_coords(), + ) + + +def gen_multi_line_string(): + return 'MULTILINESTRING ({}, {})'.format( + _gen_line_string_without_prefix(), + _gen_line_string_without_prefix(), + ) + + +def gen_multi_polygon(): + return 'MULTIPOLYGON ({}, {})'.format( + _gen_polygon_without_prefix(), + _gen_polygon_without_prefix(), + ) + + +def gen_geometry(): + return gen_point() + + +def gen_geometry_collection(): + return 'GEOMETRYCOLLECTION ({})'.format( + gen_point(), + ) diff --git a/runtests.py b/runtests.py index 9d620d0..9576483 100755 --- a/runtests.py +++ b/runtests.py @@ -1,17 +1,21 @@ #!/usr/bin/env python -from os.path import dirname, join import sys -from optparse import OptionParser import warnings +from optparse import OptionParser +from os.path import dirname, join + import django + def parse_args(): parser = OptionParser() parser.add_option('--use-tz', dest='USE_TZ', action='store_true') parser.add_option('--postgresql', dest='USE_POSTGRESQL', action='store_true') + parser.add_option('--postgis', dest='USE_POSTGIS', action='store_true') return parser.parse_args() + def configure_settings(options): from django.conf import settings @@ -25,7 +29,7 @@ def configure_settings(options): 'NAME': ':memory:', } }, - INSTALLED_APPS = ( + INSTALLED_APPS=( 'test.generic', 'django.contrib.contenttypes', 'test_without_migrations', @@ -38,9 +42,13 @@ def configure_settings(options): MIDDLEWARE_CLASSES=(), ) if getattr(options, 'USE_POSTGRESQL', False): + if getattr(options, 'USE_POSTGIS', False): + engine = 'django.contrib.gis.db.backends.postgis' + else: + engine = 'django.db.backends.postgresql_psycopg2' params['DATABASES'] = { 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'ENGINE': engine, 'NAME': 'model_mommy', 'TEST_NAME': 'test_model_mommy', 'USER': 'postgres', @@ -59,6 +67,7 @@ def configure_settings(options): return settings + # We only need this if HstoreFields are a possibility from django.db.backends.signals import connection_created from django.test.runner import DiscoverRunner @@ -86,13 +95,13 @@ def get_runner(settings): Asks Django for the TestRunner defined in settings or the default one. ''' from django.test.utils import get_runner + extra_apps = [] if getattr(options, 'USE_POSTGRESQL', False): - setattr(settings, 'INSTALLED_APPS', - ['django.contrib.postgres'] - + list(getattr(settings, 'INSTALLED_APPS'))) - setattr(settings, 'INSTALLED_APPS', - ['django.contrib.auth'] - + list(getattr(settings, 'INSTALLED_APPS'))) + extra_apps.append('django.contrib.postgres') + if getattr(options, 'USE_POSTGIS', False): + extra_apps.append('django.contrib.gis') + extra_apps.append('django.contrib.auth') + setattr(settings, 'INSTALLED_APPS', extra_apps + list(getattr(settings, 'INSTALLED_APPS'))) from test_without_migrations.management.commands._base import DisableMigrations setattr(settings, 'MIGRATION_MODULES', DisableMigrations()) TestRunner = get_runner(settings) @@ -114,4 +123,6 @@ def runtests(options=None, labels=None): if __name__ == '__main__': options, labels = parse_args() + if getattr(options, 'USE_POSTGIS', False): + setattr(options, 'USE_POSTGRESQL', True) runtests(options, labels) diff --git a/test/generic/models.py b/test/generic/models.py index 0fa4ad5..d9c55b1 100755 --- a/test/generic/models.py +++ b/test/generic/models.py @@ -1,4 +1,4 @@ -#coding: utf-8 +# coding: utf-8 ####################################### # TESTING PURPOSE ONLY MODELS!! # @@ -7,13 +7,19 @@ from decimal import Decimal from tempfile import gettempdir -from django.db import models +from model_mommy.gis import MOMMY_GIS + +if MOMMY_GIS: + from django.contrib.gis.db import models +else: + from django.db import models from django.core.files.storage import FileSystemStorage from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.fields import GenericRelation, GenericForeignKey -from .fields import * +from fields import CustomFieldWithGenerator, CustomFieldWithoutGenerator, FakeListField, CustomForeignKey + from model_mommy.timezone import smart_datetime as datetime import datetime as base_datetime @@ -101,7 +107,7 @@ class Person(models.Model): # New at Django 1.8 pass - #backward compatibility with Django 1.1 + # backward compatibility with Django 1.1 try: wanted_games_qtd = models.BigIntegerField() except AttributeError: @@ -112,9 +118,18 @@ class Person(models.Model): except AttributeError: pass + if MOMMY_GIS: + geom = models.GeometryField() + point = models.PointField() + line_string = models.LineStringField() + polygon = models.PolygonField() + multi_point = models.MultiPointField() + multi_line_string = models.MultiLineStringField() + multi_polygon = models.MultiPolygonField() + geom_collection = models.GeometryCollectionField() -class Dog(models.Model): +class Dog(models.Model): class Meta: order_with_respect_to = 'owner' @@ -123,9 +138,11 @@ class Meta: created = models.DateTimeField(auto_now_add=True) friends_with = models.ManyToManyField('Dog') + class GuardDog(Dog): pass + class LonelyPerson(models.Model): only_friend = models.OneToOneField(Person, on_delete=models.CASCADE) @@ -153,9 +170,11 @@ class Store(models.Model): employees = models.ManyToManyField(Person, related_name='employers') suppliers = models.ManyToManyField(Person, related_name='suppliers', blank=True, null=True) + class DummyEmptyModel(models.Model): pass + class DummyIntModel(models.Model): int_field = models.IntegerField() small_int_field = models.SmallIntegerField() @@ -212,6 +231,7 @@ class DummyBlankFieldsModel(models.Model): blank_char_field = models.CharField(max_length=50, blank=True) blank_text_field = models.TextField(max_length=300, blank=True) + class DummyDefaultFieldsModel(models.Model): default_id = models.AutoField(primary_key=True) default_char_field = models.CharField(max_length=50, default='default') @@ -246,12 +266,13 @@ class DummyMultipleInheritanceModel(DummyDefaultFieldsModel, Person): my_id = models.AutoField(primary_key=True) my_dummy_field = models.IntegerField() + class Ambiguous(models.Model): name = models.CharField(max_length=20) class School(models.Model): - name = models.CharField(max_length = 10) + name = models.CharField(max_length=10) students = models.ManyToManyField(Person, through='SchoolEnrollment') @@ -304,6 +325,7 @@ class CastMember(models.Model): movie = models.ForeignKey(Movie, related_name='cast_members', on_delete=models.CASCADE) person = models.ForeignKey(Person, on_delete=models.CASCADE) + class DummyGenericIPAddressFieldModel(models.Model): ipv4_field = models.GenericIPAddressField(protocol='IPv4') ipv6_field = models.GenericIPAddressField(protocol='IPv6') diff --git a/test/generic/tests/test_filling_fields.py b/test/generic/tests/test_filling_fields.py index cb0c90a..e792d40 100644 --- a/test/generic/tests/test_filling_fields.py +++ b/test/generic/tests/test_filling_fields.py @@ -2,19 +2,19 @@ from decimal import Decimal from os.path import abspath from tempfile import gettempdir - from unittest import skipUnless -from django.test import TestCase + from django.conf import settings from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ValidationError -from django.db import models as django_models from django.core.files import File from django.core.files.images import ImageFile - +from django.db import models as django_models +from django.test import TestCase from six import text_type, string_types, binary_type from model_mommy import mommy +from model_mommy.gis import MOMMY_GIS from model_mommy.random_gen import gen_related from test.generic import models from test.generic.generators import gen_value_string @@ -60,14 +60,16 @@ HStoreField = None from django.core.validators import validate_ipv4_address + try: from django.core.validators import validate_ipv6_address, validate_ipv46_address except ImportError: def validate_ipv6_address(v): raise ValidationError() - validate_ipv46_address = validate_ipv6_address + validate_ipv46_address = validate_ipv6_address + __all__ = [ 'StringFieldsFilling', 'BooleanFieldsFilling', 'DateTimeFieldsFilling', 'DateFieldsFilling', 'FillingIntFields', 'FillingPositiveIntFields', @@ -193,7 +195,6 @@ def test_fill_TimeField_with_a_time(self): class UUIDFieldsFilling(FieldFillingTestCase): - if UUIDField: def test_fill_UUIDField_with_uuid_object(self): import uuid @@ -205,24 +206,23 @@ def test_fill_UUIDField_with_uuid_object(self): class ArrayFieldsFilling(FieldFillingTestCase): - if ArrayField: def test_fill_ArrayField_with_empty_array(self): self.assertEqual(self.person.acquaintances, []) class JSONFieldsFilling(FieldFillingTestCase): - if JSONField: def test_fill_JSONField_with_empty_dict(self): self.assertEqual(self.person.data, {}) -class HStoreFieldsFilling(FieldFillingTestCase): +class HStoreFieldsFilling(FieldFillingTestCase): if HStoreField: def test_fill_HStoreField_with_empty_dict(self): self.assertEqual(self.person.hstore_data, {}) + class FillingIntFields(TestCase): def setUp(self): @@ -399,7 +399,7 @@ def test_uses_generator_defined_on_settings_for_custom_field(self): def test_uses_generator_defined_as_string_on_settings_for_custom_field(self): """Should import and use the function present in the import path defined in settings""" generator_dict = {'test.generic.fields.CustomFieldWithGenerator': - 'test.generic.generators.gen_value_string'} + 'test.generic.generators.gen_value_string'} setattr(settings, 'MOMMY_CUSTOM_FIELDS_GEN', generator_dict) obj = mommy.make(models.CustomFieldWithGeneratorModel) self.assertEqual("value", obj.custom_value) @@ -426,6 +426,7 @@ def test_uses_generator_function_for_custom_foreignkey(self): def test_can_override_django_default_field_functions_genereator(self): def gen_char(): return 'Some value' + mommy.generators.add('django.db.models.fields.CharField', gen_char) person = mommy.make(models.Person) @@ -440,3 +441,31 @@ def test_filling_AutoField(self): field = models.DummyEmptyModel._meta.get_field('id') self.assertIsInstance(field, django_models.AutoField) self.assertIsInstance(obj.id, int) + + +@skipUnless(MOMMY_GIS, "GIS support required for GIS fields") +class GisFieldsFilling(FieldFillingTestCase): + + def test_fill_PointField_valid(self): + self.assertTrue(self.person.point.valid) + + def test_fill_LineStringField_valid(self): + self.assertTrue(self.person.line_string.valid) + + def test_fill_PolygonField_valid(self): + self.assertTrue(self.person.polygon.valid) + + def test_fill_MultiPointField_valid(self): + self.assertTrue(self.person.multi_point.valid) + + def test_fill_MultiLineStringField_valid(self): + self.assertTrue(self.person.multi_line_string.valid) + + def test_fill_MultiPolygonField_valid(self): + self.assertTrue(self.person.multi_polygon.valid) + + def test_fill_GeometryField_valid(self): + self.assertTrue(self.person.geom.valid) + + def test_fill_GeometryCollectionField_valid(self): + self.assertTrue(self.person.geom_collection.valid) From 538e62b9dc6660be73e963e1108464a1ebc1fd50 Mon Sep 17 00:00:00 2001 From: Dylan Verheul Date: Tue, 2 Jan 2018 11:29:55 +0100 Subject: [PATCH 3/8] Simplify tests, fix tox matrix --- model_mommy/random_gen.py | 9 +++------ test/generic/models.py | 4 +++- test/generic/tests/test_filling_fields.py | 19 +++++++++++-------- tox.ini | 7 +++++-- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/model_mommy/random_gen.py b/model_mommy/random_gen.py index e4befba..310205f 100644 --- a/model_mommy/random_gen.py +++ b/model_mommy/random_gen.py @@ -308,22 +308,19 @@ def gen_polygon(): def gen_multi_point(): - return 'MULTIPOINT (({}), ({}))'.format( - gen_coords(), + return 'MULTIPOINT (({}))'.format( gen_coords(), ) def gen_multi_line_string(): - return 'MULTILINESTRING ({}, {})'.format( - _gen_line_string_without_prefix(), + return 'MULTILINESTRING ({})'.format( _gen_line_string_without_prefix(), ) def gen_multi_polygon(): - return 'MULTIPOLYGON ({}, {})'.format( - _gen_polygon_without_prefix(), + return 'MULTIPOLYGON ({})'.format( _gen_polygon_without_prefix(), ) diff --git a/test/generic/models.py b/test/generic/models.py index d9c55b1..2cb7de3 100755 --- a/test/generic/models.py +++ b/test/generic/models.py @@ -1,5 +1,7 @@ # coding: utf-8 +from __future__ import absolute_import + ####################################### # TESTING PURPOSE ONLY MODELS!! # # DO NOT ADD THE APP TO INSTALLED_APPS# @@ -18,7 +20,7 @@ from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.fields import GenericRelation, GenericForeignKey -from fields import CustomFieldWithGenerator, CustomFieldWithoutGenerator, FakeListField, CustomForeignKey +from .fields import CustomFieldWithGenerator, CustomFieldWithoutGenerator, FakeListField, CustomForeignKey from model_mommy.timezone import smart_datetime as datetime import datetime as base_datetime diff --git a/test/generic/tests/test_filling_fields.py b/test/generic/tests/test_filling_fields.py index e792d40..a6d90cb 100644 --- a/test/generic/tests/test_filling_fields.py +++ b/test/generic/tests/test_filling_fields.py @@ -446,26 +446,29 @@ def test_filling_AutoField(self): @skipUnless(MOMMY_GIS, "GIS support required for GIS fields") class GisFieldsFilling(FieldFillingTestCase): + def assertGeomValid(self, geom): + self.assertTrue(geom.valid, geom.valid_reason) + def test_fill_PointField_valid(self): - self.assertTrue(self.person.point.valid) + self.assertGeomValid(self.person.point) def test_fill_LineStringField_valid(self): - self.assertTrue(self.person.line_string.valid) + self.assertGeomValid(self.person.line_string) def test_fill_PolygonField_valid(self): - self.assertTrue(self.person.polygon.valid) + self.assertGeomValid(self.person.polygon) def test_fill_MultiPointField_valid(self): - self.assertTrue(self.person.multi_point.valid) + self.assertGeomValid(self.person.multi_point) def test_fill_MultiLineStringField_valid(self): - self.assertTrue(self.person.multi_line_string.valid) + self.assertGeomValid(self.person.multi_line_string) def test_fill_MultiPolygonField_valid(self): - self.assertTrue(self.person.multi_polygon.valid) + self.assertGeomValid(self.person.multi_polygon) def test_fill_GeometryField_valid(self): - self.assertTrue(self.person.geom.valid) + self.assertGeomValid(self.person.geom) def test_fill_GeometryCollectionField_valid(self): - self.assertTrue(self.person.geom_collection.valid) + self.assertGeomValid(self.person.geom_collection) diff --git a/tox.ini b/tox.ini index 1656c47..2a8425d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,8 @@ [tox] -envlist = {py27,py35,py36}-django{18,19,110,111,20}-{postgresql,sqlite} +envlist = + py27-django{18,19,110,111}-{postgresql,sqlite} + py35-django{18,19,110,111,20}-{postgresql,sqlite} + py36-django{20}-{postgresql,sqlite} [testenv] setenv= @@ -22,5 +25,5 @@ deps = postgresql: psycopg2 commands= - postgresql: {toxinidir}/runtests.py --postgresql + postgresql: {toxinidir}/runtests.py --postgis sqlite: {toxinidir}/runtests.py --use-tz From 5332bf08adfe23bd94d80a28feed392a81c35e1d Mon Sep 17 00:00:00 2001 From: Bernardo Fontes Date: Fri, 5 Jan 2018 11:47:11 -0200 Subject: [PATCH 4/8] Update Changelog.txt --- Changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.txt b/Changelog.txt index 6636f65..cfbcee5 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -4,6 +4,7 @@ TODO Development ----------- +- Support to GIS fields 1.5.0 ----- From e53497509b74d18168073bc1ef31ffa2713a1955 Mon Sep 17 00:00:00 2001 From: Dylan Verheul Date: Wed, 10 Jan 2018 10:16:40 +0100 Subject: [PATCH 5/8] Update Changelog.txt --- Changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index cfbcee5..a237e79 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -4,7 +4,7 @@ TODO Development ----------- -- Support to GIS fields +- Support for GIS fields when `django.contrib.gis` is installed 1.5.0 ----- From de6fcb5539f36ef783ac4074e820813cbf13662c Mon Sep 17 00:00:00 2001 From: Bernardo Fontes Date: Thu, 11 Jan 2018 11:47:09 -0200 Subject: [PATCH 6/8] Update Changelog.txt --- Changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.txt b/Changelog.txt index a237e79..33ad1b6 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -5,6 +5,7 @@ TODO Development ----------- - Support for GIS fields when `django.contrib.gis` is installed +- Do not create refrence if FK is specified with id (_id) 1.5.0 ----- From 31c8d0059377f71e90d9d7859b42db99b6f421f3 Mon Sep 17 00:00:00 2001 From: Bernardo Fontes Date: Tue, 16 Jan 2018 18:52:46 -0200 Subject: [PATCH 7/8] Version bump --- model_mommy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model_mommy/__init__.py b/model_mommy/__init__.py index f373c8f..1ab1419 100644 --- a/model_mommy/__init__.py +++ b/model_mommy/__init__.py @@ -1,5 +1,5 @@ #coding:utf-8 -__version__ = '1.5.0' +__version__ = '1.5.1' __title__ = 'model_mommy' __author__ = 'Vanderson Mota' __license__ = 'Apache 2.0' From c346f461c9e447aef2999b9b76ed6f01f35065ab Mon Sep 17 00:00:00 2001 From: Bernardo Fontes Date: Tue, 16 Jan 2018 18:52:52 -0200 Subject: [PATCH 8/8] Update changelog --- Changelog.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index 33ad1b6..989f8f6 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -4,6 +4,9 @@ TODO Development ----------- + +1.5.1 +----- - Support for GIS fields when `django.contrib.gis` is installed - Do not create refrence if FK is specified with id (_id)