Skip to content

Commit db7132c

Browse files
authored
Merge pull request #173 from imomaliev/master
Support django 2.1, DRF 3.9 and use django-filters > 2.0
2 parents f1fcda0 + 58a2ebe commit db7132c

File tree

8 files changed

+103
-7
lines changed

8 files changed

+103
-7
lines changed

.travis.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ services:
1212

1313
matrix:
1414
include:
15-
- env: TOXENV=py27-django111
16-
python: 2.7
1715
- env: TOXENV=py34-django111
1816
python: 3.4
1917
- env: TOXENV=py35-django111
@@ -26,6 +24,34 @@ matrix:
2624
python: 3.5
2725
- env: TOXENV=py36-django20
2826
python: 3.6
27+
# https://github.com/travis-ci/travis-ci/issues/9815
28+
- env: TOXENV=py37-django20
29+
python: 3.7
30+
dist: xenial
31+
sudo: true
32+
addons:
33+
postgresql: "9.4"
34+
apt:
35+
packages:
36+
- postgresql-9.4-postgis-2.4
37+
services:
38+
- postgresql
39+
- env: TOXENV=py35-django21
40+
python: 3.5
41+
- env: TOXENV=py36-django21
42+
python: 3.6
43+
# https://github.com/travis-ci/travis-ci/issues/9815
44+
- env: TOXENV=py37-django21
45+
python: 3.7
46+
dist: xenial
47+
sudo: true
48+
addons:
49+
postgresql: "9.4"
50+
apt:
51+
packages:
52+
- postgresql-9.4-postgis-2.4
53+
services:
54+
- postgresql
2955

3056
branches:
3157
only:

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM python:3.7-alpine3.8
2+
3+
# postgresql-client is required by psql
4+
# postgresql-dev musl-dev gcc are required by psycopg
5+
# NOTE: there is py3-psycopg2
6+
# gdal-dev geos-dev proj4-dev are required by geodjango
7+
# NOTE: we actually need gdal-dev not gdal
8+
9+
# TODO: optimize installation by using --virtual
10+
RUN apk update && apk upgrade \
11+
&& apk add postgresql-client postgresql-dev musl-dev gcc \
12+
&& apk add --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
13+
gdal-dev \
14+
geos-dev \
15+
proj4-dev
16+
17+
ENV PYTHONUNBUFFERED=1 \
18+
PYTHONIOENCODING=UTF-8
19+
20+
WORKDIR /project
21+
22+
RUN pip install django
23+
24+
COPY requirements-test.txt /project/
25+
26+
RUN pip install -r requirements-test.txt

docker-compose.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: "3.7"
2+
3+
4+
services:
5+
6+
backend:
7+
build:
8+
context: .
9+
dockerfile: Dockerfile
10+
depends_on:
11+
- postgres
12+
volumes:
13+
- root_dir:/root
14+
- ./rest_framework_gis:/project/rest_framework_gis
15+
- ./tests:/project/tests
16+
- ./runtests.py:/project/runtests.py
17+
command: ["./runtests.py"]
18+
19+
postgres:
20+
image: mdillon/postgis:10-alpine
21+
volumes:
22+
- postgres_data:/var/lib/postgresql/data
23+
24+
25+
volumes:
26+
postgres_data:
27+
root_dir:

requirements-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
psycopg2
22
coverage==3.7.1 # rq.filter: >=3,<4
33
coveralls
4-
django-filter>=0.15,<1.2
4+
django-filter>=2.0
55
contexttimer

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
djangorestframework>=3.3,<3.9
1+
djangorestframework>=3.3,<3.10

tests/django_restframework_gis_tests/tests.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import json
99
import pickle
1010

11+
from unittest import skipIf
12+
1113
from django.test import TestCase
1214
from django.contrib.gis.geos import GEOSGeometry, Polygon, Point
1315
try:
@@ -16,12 +18,16 @@
1618
from django.core.urlresolvers import reverse
1719
from django.core.exceptions import ImproperlyConfigured
1820

21+
import rest_framework
22+
1923
from rest_framework_gis import serializers as gis_serializers
2024
from rest_framework_gis.fields import GeoJsonDict
2125

2226
from .models import Location, LocatedFile
2327
from .serializers import LocationGeoSerializer
2428

29+
is_pre_drf_39 = not rest_framework.VERSION.startswith('3.9')
30+
2531

2632
class TestRestFrameworkGis(TestCase):
2733
def setUp(self):
@@ -472,7 +478,16 @@ def test_post_geojson_location_list_HTML_web_form_WKT(self):
472478
location = Location.objects.all()[0]
473479
self.assertEqual(location.name, "HTML test WKT")
474480

481+
@skipIf(is_pre_drf_39, 'Skip this test if DRF < 3.9')
475482
def test_geojson_HTML_widget_value(self):
483+
self._create_locations()
484+
response = self.client.get(self.geojson_location_list_url, HTTP_ACCEPT='text/html')
485+
self.assertContains(response, '<textarea name="geometry"')
486+
self.assertContains(response, '"type": "Point"')
487+
self.assertContains(response, '"coordinates": [')
488+
489+
@skipIf(not is_pre_drf_39, 'Skip this test if DRF >= 3.9')
490+
def test_geojson_HTML_widget_value_pre_drf_39(self):
476491
self._create_locations()
477492
response = self.client.get(self.geojson_location_list_url, HTTP_ACCEPT='text/html')
478493
self.assertContains(response, '<textarea name="geometry"')

tests/django_restframework_gis_tests/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class GeojsonLocationNoIdDetails(generics.RetrieveUpdateDestroyAPIView):
132132

133133

134134
class LocationFilter(GeoFilterSet):
135-
contains_properly = GeometryFilter(name='geometry',
135+
contains_properly = GeometryFilter(field_name='geometry',
136136
lookup_expr='contains_properly')
137137

138138
class Meta:

tox.ini

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[tox]
22
envlist =
3-
py{27,34,35,36,py,py3}-django111{,-pytest}
4-
py{34,35,36,py3}-django20{,-pytest}
3+
py{34,35,36,py3}-django111{,-pytest}
4+
py{34,35,36,37,py3}-django20{,-pytest}
5+
py{35,36,37,py3}-django21{,-pytest}
56

67
[testenv]
78
usedevelop = true
@@ -17,6 +18,7 @@ commands =
1718
deps =
1819
django111: Django>=1.11,<2.0
1920
django20: Django>=2.0,<2.1
21+
django21: Django>=2.1,<2.2
2022
-rrequirements-test.txt
2123
pytest: pytest
2224
pytest: pytest-django

0 commit comments

Comments
 (0)