1. Fixed bulk_update testing issue for django 2.1

2. Added python 3.8 and django 3.0 to travis testing
3. Split requirements.txt and requirements-test.txt
This commit is contained in:
M1ha 2020-02-07 11:14:39 +05:00
parent 54923e03bf
commit 210c36a127
5 changed files with 21 additions and 5 deletions

View File

@ -33,6 +33,7 @@ addons:
python: python:
- 3.6 - 3.6
- 3.7 - 3.7
- 3.8
env: env:
- PG=9.6 DJANGO=2.1 - PG=9.6 DJANGO=2.1
@ -41,6 +42,9 @@ env:
- PG=9.6 DJANGO=2.2 - PG=9.6 DJANGO=2.2
- PG=10 DJANGO=2.2 - PG=10 DJANGO=2.2
- PG=11 DJANGO=2.2 - PG=11 DJANGO=2.2
- PG=9.6 DJANGO=3.0
- PG=10 DJANGO=3.0
- PG=11 DJANGO=3.0
before_install: before_install:
# Use default PostgreSQL 11 port # Use default PostgreSQL 11 port
@ -60,9 +64,8 @@ install:
- sudo apt-get install clickhouse-client clickhouse-server clickhouse-common-static - sudo apt-get install clickhouse-client clickhouse-server clickhouse-common-static
- sudo service clickhouse-server restart - sudo service clickhouse-server restart
- pip install -r requirements.txt - pip install -r requirements-test.txt
- pip install -q Django==$DJANGO.* - pip install -q Django==$DJANGO.*
- pip install redis
- python setup.py -q install - python setup.py -q install
before_script: before_script:

11
requirements-test.txt Normal file
View File

@ -0,0 +1,11 @@
Django (>=1.7)
pytz
six
typing
psycopg2
infi.clickhouse-orm
celery
statsd
django-pg-returning
django-pg-bulk-update
redis

View File

@ -6,4 +6,3 @@ psycopg2
infi.clickhouse-orm infi.clickhouse-orm
celery celery
statsd statsd
django-pg-returning

View File

@ -74,7 +74,7 @@ class ClickHouseSyncBulkUpdateQuerySetMixin(ClickHouseSyncRegisterMixin, BulkUpd
def _decorate_method(self, name: str, operation: str, args, kwargs): def _decorate_method(self, name: str, operation: str, args, kwargs):
if not hasattr(super(), name): if not hasattr(super(), name):
raise AttributeError(name) raise AttributeError("QuerySet has no attribute %s. Is django-pg-bulk-update library installed?" % name)
func = getattr(super(), name) func = getattr(super(), name)
original_returning = kwargs.pop('returning', None) original_returning = kwargs.pop('returning', None)

View File

@ -1,5 +1,7 @@
import datetime import datetime
from unittest import skipIf
import django
from django.test import TransactionTestCase from django.test import TransactionTestCase
from django.utils.timezone import now from django.utils.timezone import now
@ -61,6 +63,7 @@ class TestOperations(TransactionTestCase):
self.assertSetEqual({('insert', "%s.%d" % (self.db_alias, instance.pk)) for instance in items}, self.assertSetEqual({('insert', "%s.%d" % (self.db_alias, instance.pk)) for instance in items},
set(self.storage.get_operations(self.clickhouse_model.get_import_key(), 10))) set(self.storage.get_operations(self.clickhouse_model.get_import_key(), 10)))
@skipIf(django.VERSION < (2, 2), "bulk_update method has been introduced in django 2.2")
def test_native_bulk_update(self): def test_native_bulk_update(self):
items = list(self.django_model.objects.filter(pk__in={1, 2})) items = list(self.django_model.objects.filter(pk__in={1, 2}))
for instance in items: for instance in items: