Skip to content

Commit

Permalink
Merge pull request #163 from onaio/149-django-upgrade
Browse files Browse the repository at this point in the history
Support Django version 2.2 and 3.0
  • Loading branch information
moshthepitt committed Jan 22, 2020
2 parents 31f08c6 + 25c97cf commit 0e4dd44
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 24 deletions.
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
sudo: required
dist: trusty
dist: xenial
language: python
matrix:
include:
- python: 3.6
env: TOXENV=py36
env: TOXENV=py36-django22
- python: 3.6
env: TOXENV=py36-django30
- python: 3.6
env: TOXENV=flake8
- python: 3.6
env: TOXENV=pylint
- python: 3.6
env: TOXENV=black
services:
- postgresql
addons:
postgresql: "9.6"
apt:
packages:
- postgresql-9.6-postgis-2.3
- postgresql-9.6-postgis-2.4
- gdal-bin
- libgdal-dev
sources:
- sourceline: 'ppa:ubuntugis/ubuntugis-unstable'
before_script:
- psql -c 'CREATE DATABASE ona_tasking;' -U postgres
- psql -c 'CREATE EXTENSION postgis;' -U postgres -d ona_tasking
Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ black = "==19.10b0"

[packages]
e1839a8 = {editable = true,path = "."}
ona-tasking = {editable = true,path = "."}
36 changes: 27 additions & 9 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
url="https://github.com/onaio/tasking",
packages=find_packages(exclude=["docs", "tests"]),
install_requires=[
"Django >= 1.11.19, < 2.1",
"Django >= 2.2",
"python-dateutil",
"markdown", # adds markdown support for browsable REST API
"django-filter", # for filtering in the API
Expand All @@ -25,6 +25,7 @@
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Framework :: Django",
"Framework :: Django :: 1.11",
"Framework :: Django :: 2.2",
"Framework :: Django :: 3.0",
],
)
3 changes: 2 additions & 1 deletion tests/serializers/test_segment_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def test_validate_bad_data(self):
name="Rule Zero",
description="Some description",
target_content_type=self.task_type.id,
active=False,
target_field="invalid_field",
target_field_value=6,
target_app_label="tasking",
Expand All @@ -85,5 +86,5 @@ def test_validate_bad_data(self):
self.assertFalse(instance.is_valid())
self.assertEqual(
"Task has no field named 'invalid_field'",
str(instance.errors["target_field"][0]),
instance.errors["target_field"][0],
)
9 changes: 2 additions & 7 deletions tests/viewsets/test_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import os

from django.test import override_settings
from django.utils import six

import pytz
from model_mommy import mommy
Expand Down Expand Up @@ -117,9 +116,7 @@ def test_create_location_with_shapefile_nested_multipolygons(self):
response = view(request=request)
self.assertEqual(response.status_code, 400)
self.assertIn("shapefile", response.data.keys())
self.assertEqual(
INVALID_SHAPEFILE, six.text_type(response.data["shapefile"][0])
)
self.assertEqual(INVALID_SHAPEFILE, response.data["shapefile"][0])

# should work
with self.settings(TASKING_SHAPEFILE_ALLOW_NESTED_MULTIPOLYGONS=True):
Expand Down Expand Up @@ -151,9 +148,7 @@ def test_create_location_with_shapefile_ignore_invalid(self):
response = view(request=request)
self.assertEqual(response.status_code, 400)
self.assertIn("shapefile", response.data.keys())
self.assertEqual(
INVALID_SHAPEFILE, six.text_type(response.data["shapefile"][0])
)
self.assertEqual(INVALID_SHAPEFILE, response.data["shapefile"][0])

# should work
with self.settings(TASKING_SHAPEFILE_IGNORE_INVALID_TYPES=True):
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py36
py36-django{22,30}
flake8
pylint
black
Expand All @@ -22,7 +22,7 @@ commands =
pipenv sync --dev
pylint --rcfile={toxinidir}/.pylintrc {toxinidir}/tasking

[testenv: black]
[testenv:black]
deps =
black
pipenv
Expand All @@ -38,6 +38,8 @@ deps =
basepython = python3.6
commands =
pipenv sync --dev
django22: pip install Django>=2.2,<2.3
django30: pip install Django>=3.0,<3.1
coverage erase
coverage run --include="tasking/**.*" --omit="tests/**.*,tasking/migrations/**.*" manage.py test {toxinidir}/tests -v 2
coverage report

0 comments on commit 0e4dd44

Please sign in to comment.