Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support django 2.1, DRF 3.9 and use django-filters > 2.0 #173

Merged
merged 7 commits into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ services:

matrix:
include:
- env: TOXENV=py27-django111
python: 2.7
- env: TOXENV=py34-django111
python: 3.4
- env: TOXENV=py35-django111
Expand All @@ -26,6 +24,34 @@ matrix:
python: 3.5
- env: TOXENV=py36-django20
python: 3.6
# https://github.com/travis-ci/travis-ci/issues/9815
- env: TOXENV=py37-django20
python: 3.7
dist: xenial
imomaliev marked this conversation as resolved.
Show resolved Hide resolved
sudo: true
addons:
postgresql: "9.4"
apt:
packages:
- postgresql-9.4-postgis-2.4
services:
- postgresql
- env: TOXENV=py35-django21
python: 3.5
- env: TOXENV=py36-django21
python: 3.6
# https://github.com/travis-ci/travis-ci/issues/9815
- env: TOXENV=py37-django21
python: 3.7
dist: xenial
sudo: true
addons:
postgresql: "9.4"
apt:
packages:
- postgresql-9.4-postgis-2.4
services:
- postgresql

branches:
only:
Expand Down
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM python:3.7-alpine3.8

# postgresql-client is required by psql
# postgresql-dev musl-dev gcc are required by psycopg
# NOTE: there is py3-psycopg2
# gdal-dev geos-dev proj4-dev are required by geodjango
# NOTE: we actually need gdal-dev not gdal

# TODO: optimize installation by using --virtual
RUN apk update && apk upgrade \
&& apk add postgresql-client postgresql-dev musl-dev gcc \
&& apk add --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
gdal-dev \
geos-dev \
proj4-dev

ENV PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=UTF-8

WORKDIR /project

RUN pip install django

COPY requirements-test.txt /project/

RUN pip install -r requirements-test.txt
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "3.7"


services:

backend:
build:
context: .
dockerfile: Dockerfile
depends_on:
- postgres
volumes:
- root_dir:/root
- ./rest_framework_gis:/project/rest_framework_gis
- ./tests:/project/tests
- ./runtests.py:/project/runtests.py
command: ["./runtests.py"]

postgres:
image: mdillon/postgis:10-alpine
volumes:
- postgres_data:/var/lib/postgresql/data


volumes:
postgres_data:
root_dir:
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
psycopg2
coverage==3.7.1 # rq.filter: >=3,<4
coveralls
django-filter>=0.15,<1.2
django-filter>=2.0
contexttimer
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
djangorestframework>=3.3,<3.9
djangorestframework>=3.3,<3.10
15 changes: 15 additions & 0 deletions tests/django_restframework_gis_tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import json
import pickle

from unittest import skipIf

from django.test import TestCase
from django.contrib.gis.geos import GEOSGeometry, Polygon, Point
try:
Expand All @@ -16,12 +18,16 @@
from django.core.urlresolvers import reverse
from django.core.exceptions import ImproperlyConfigured

import rest_framework

from rest_framework_gis import serializers as gis_serializers
from rest_framework_gis.fields import GeoJsonDict

from .models import Location, LocatedFile
from .serializers import LocationGeoSerializer

is_pre_drf_39 = not rest_framework.VERSION.startswith('3.9')


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

@skipIf(is_pre_drf_39, 'Skip this test if DRF < 3.9')
def test_geojson_HTML_widget_value(self):
imomaliev marked this conversation as resolved.
Show resolved Hide resolved
self._create_locations()
response = self.client.get(self.geojson_location_list_url, HTTP_ACCEPT='text/html')
self.assertContains(response, '<textarea name="geometry"')
self.assertContains(response, '"type": "Point"')
self.assertContains(response, '"coordinates": [')

@skipIf(not is_pre_drf_39, 'Skip this test if DRF >= 3.9')
def test_geojson_HTML_widget_value_pre_drf_39(self):
self._create_locations()
response = self.client.get(self.geojson_location_list_url, HTTP_ACCEPT='text/html')
self.assertContains(response, '<textarea name="geometry"')
Expand Down
2 changes: 1 addition & 1 deletion tests/django_restframework_gis_tests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class GeojsonLocationNoIdDetails(generics.RetrieveUpdateDestroyAPIView):


class LocationFilter(GeoFilterSet):
contains_properly = GeometryFilter(name='geometry',
contains_properly = GeometryFilter(field_name='geometry',
lookup_expr='contains_properly')

class Meta:
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[tox]
envlist =
py{27,34,35,36,py,py3}-django111{,-pytest}
py{34,35,36,py3}-django20{,-pytest}
py{34,35,36,py3}-django111{,-pytest}
py{34,35,36,37,py3}-django20{,-pytest}
py{35,36,37,py3}-django21{,-pytest}

[testenv]
usedevelop = true
Expand All @@ -17,6 +18,7 @@ commands =
deps =
django111: Django>=1.11,<2.0
django20: Django>=2.0,<2.1
django21: Django>=2.1,<2.2
-rrequirements-test.txt
pytest: pytest
pytest: pytest-django