From 2634883d17ab112501e92de75e1215072f059ae0 Mon Sep 17 00:00:00 2001 From: Tommy Li Date: Sun, 11 Feb 2018 10:23:30 -0800 Subject: [PATCH] django 2 (#74) * also target django 2 in tests * travis * add on_delete to foreign keyed models * fix last test * version bump --- .travis.yml | 1 + CHANGES.md | 9 +++++++++ setup.py | 4 ++-- tests/models.py | 4 ++-- tests/test_fields.py | 3 ++- tox.ini | 3 ++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2433dd9..08d10ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ env: - TOX_ENV=py36-dj19 - TOX_ENV=py36-dj110 - TOX_ENV=py36-dj111 + - TOX_ENV=py36-dj2 - TOX_ENV=py36-djdev matrix: fast_finish: true diff --git a/CHANGES.md b/CHANGES.md index 053c332..706a8d1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,7 +1,16 @@ Changelog ========= +2.1.0 (Jan 5th 2018) +------------------ + +### Official Support for Django 2.0.0 + +- Support for Django 2.0.0. + + 2.0.0 (Sep 10th 2017) +------------------ ### Small updates diff --git a/setup.py b/setup.py index 5508cea..cc6d162 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = '2.0.0' +version = '2.1.0' def get_requirements(file_path): @@ -18,7 +18,7 @@ def get_requirements(file_path): url='https://github.com/JBKahn/django-sharding', packages=find_packages(), include_package_data=True, - install_requires=get_requirements('requirements/common.txt') + ["django>=1.8,<2.0.0"], + install_requires=get_requirements('requirements/common.txt') + ["django>=1.8,<2.0.1"], tests_require=get_requirements('requirements/development.txt'), license="BSD", zip_safe=False, diff --git a/tests/models.py b/tests/models.py index 49966d1..65dba2a 100644 --- a/tests/models.py +++ b/tests/models.py @@ -85,9 +85,9 @@ class ShardStorageTable(ShardStorageModel): class ShardedByForiegnKeyModel(models.Model): - shard = ShardForeignKeyStorageField(ShardStorageTable, shard_group='default') + shard = ShardForeignKeyStorageField(ShardStorageTable, shard_group='default', on_delete=models.CASCADE) random_string = models.CharField(max_length=120) - test = models.ForeignKey(UnshardedTestModel) + test = models.ForeignKey(UnshardedTestModel, on_delete=models.CASCADE) def get_shard_key(self): return self.test.user_pk diff --git a/tests/test_fields.py b/tests/test_fields.py index e51afc0..d84b728 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -4,6 +4,7 @@ from django.conf import settings from django.db import connections from django.db.utils import DataError, IntegrityError +from django.db.models import CASCADE from django.test import TestCase from django.utils.six.moves import xrange @@ -170,7 +171,7 @@ def get_shard_key(self): class ShardForeignKeyStorageFieldTestCase(TestCase): def test_pre_save_calls_save_shard(self): - sut = ShardForeignKeyStorageField(ShardStorageTable, shard_group='default') + sut = ShardForeignKeyStorageField(ShardStorageTable, shard_group='default', on_delete=CASCADE) model_instance = object() with patch.object(sut, 'save_shard') as mock_save_shard: with self.assertRaises(Exception): diff --git a/tox.ini b/tox.ini index 09b0d60..037785b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] envlist = py27-dj{18,19,110,111,dev} - py36-dj{18,19,110,111,dev} + py36-dj{18,19,110,111,2,dev} [testenv] passenv= @@ -23,6 +23,7 @@ deps = dj19: Django>=1.9,<1.10 dj110: Django>=1.10,<1.11 dj111: Django>=1.11,<1.12 + dj2: Django>=2.0.0,<2.0.1 djdev: https://github.com/django/django/archive/master.tar.gz commands= coverage run --source=django_sharding,django_sharding_library -a setup.py test