Skip to content

Commit 3b2dd57

Browse files
authored
Merge pull request #152 from JBKahn/django3
only support django>=2.2
2 parents b26db52 + eebe6c6 commit 3b2dd57

File tree

12 files changed

+50
-133
lines changed

12 files changed

+50
-133
lines changed

.travis.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,20 @@ dist: xenial
22
language: python
33

44
python:
5+
- "3.8"
56
- "3.7"
67
- "3.6"
78
- "3.5"
8-
- "2.7"
99

1010
env:
1111
matrix:
1212
- DJANGO_VERSION=2.2
13-
- DJANGO_VERSION=2.1
14-
- DJANGO_VERSION=2.0
15-
- DJANGO_VERSION=1.11
13+
- DJANGO_VERSION=3.0
1614

1715
matrix:
1816
exclude:
19-
- python: "2.7"
20-
env: DJANGO_VERSION=2.0
21-
- python: "2.7"
22-
env: DJANGO_VERSION=2.1
23-
- python: "2.7"
24-
env: DJANGO_VERSION=2.2
17+
- python: "3.5"
18+
env: DJANGO_VERSION=3.0
2519

2620
install:
2721
- pip install tox coveralls

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
History
55
=======
66

7+
1.0.0 (2019-12-18)
8+
-------------------
9+
10+
* Drop support for python2 and Django<2.2 (the only officially supported versions of Django that aren't on 2.7) (@JBKahn)
11+
* Drop usage of django-jsonview in favor of the builtin django JsonResponse (@JBKahn)
12+
713
0.18.0 (2019-08-19)
814
-------------------
915

requirements-test.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
django-jsonview==0.5.0
2-
31
coverage>=4.0
4-
mock>=1.0.1
52
nose>=1.3.0
63
django-nose>=1.2
74
flake8>=2.1.0

setup.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
],
3737
include_package_data=True,
3838
install_requires=[
39-
'django',
40-
'django-jsonview>=0.5.0',
39+
'django>=2.0',
4140
],
4241
license="BSD",
4342
zip_safe=False,
@@ -48,11 +47,10 @@
4847
'Intended Audience :: Developers',
4948
'License :: OSI Approved :: BSD License',
5049
'Natural Language :: English',
51-
'Programming Language :: Python :: 2',
52-
'Programming Language :: Python :: 2.7',
5350
'Programming Language :: Python :: 3',
5451
'Programming Language :: Python :: 3.5',
5552
'Programming Language :: Python :: 3.6',
5653
'Programming Language :: Python :: 3.7',
54+
'Programming Language :: Python :: 3.8',
5755
],
5856
)

tests/test_decorators.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@
1212
import logging
1313
import unittest
1414

15-
try:
16-
from django.urls import reverse
17-
except ImportError:
18-
# Deprecated in Django 1.10
19-
from django.core.urlresolvers import reverse
15+
from django.urls import reverse
2016
from django.test.client import Client
2117

22-
import mock
18+
from unittest import mock
2319

2420
from watchman import settings as watchman_settings
2521
from watchman.decorators import check

tests/test_management.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
from __future__ import unicode_literals
1111

12+
from io import StringIO
1213
import unittest
1314

1415
from django.core.management import call_command
15-
from django.utils.six import StringIO
1616

1717

1818
class TestWatchman(unittest.TestCase):

tests/test_utils.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
import unittest
1313

14-
import django
15-
from mock import patch
14+
from unittest.mock import patch
1615

1716
from watchman.utils import get_cache, get_checks
1817

@@ -27,24 +26,11 @@ def assert_lists_equal(self, list1, list2):
2726
# Python 2
2827
self.assertItemsEqual(list1, list2)
2928

30-
@unittest.skipIf(
31-
django.VERSION < (1, 7),
32-
'caches interface is not added until Django 1.7',
33-
)
3429
@patch('watchman.utils.django_cache.caches', spec_set=dict)
3530
def test_get_cache_django_17_or_greater(self, get_cache_mock):
3631
get_cache('foo')
3732
get_cache_mock.__getitem__.called_once_with('foo')
3833

39-
@unittest.skipIf(
40-
django.VERSION >= (1, 7),
41-
'get_cache has been deprecated as of Django 1.7'
42-
)
43-
@patch('django.core.cache.get_cache')
44-
def test_get_cache_less_than_django_17(self, get_cache_mock):
45-
get_cache('foo')
46-
get_cache_mock.assert_called_once_with('foo')
47-
4834
def test_get_checks_returns_all_available_checks_by_default(self):
4935
checks = [check.__name__ for check in get_checks()]
5036
expected_checks = ['caches', 'databases', 'storage']

tests/test_views.py

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
from django.db.utils import DEFAULT_DB_ALIAS
1818
from django.test.testcases import TransactionTestCase
1919

20-
21-
try:
22-
from importlib import reload
23-
except ImportError: # Python < 3
24-
pass
20+
from importlib import reload
2521
import sys
2622
import unittest
2723

@@ -33,12 +29,10 @@
3329
from django.test.client import RequestFactory, Client
3430
from django.test.utils import override_settings
3531

36-
from mock import patch
32+
from unittest.mock import patch
3733

3834
from watchman import checks, views
3935

40-
PYTHON_VERSION = sys.version_info[0]
41-
4236

4337
class AuthenticatedUser(AnonymousUser):
4438
@property
@@ -55,12 +49,11 @@ def __bool__(self):
5549
return CallableTrue()
5650

5751

58-
if django.VERSION >= (1, 7):
59-
# Initialize Django
60-
django.setup()
52+
# Initialize Django
53+
django.setup()
6154

62-
# Silence MIDDLEWARE_CLASSES warning as this is not an actual Django project
63-
settings.SILENCED_SYSTEM_CHECKS = ['1_7.W001']
55+
# Silence MIDDLEWARE_CLASSES warning as this is not an actual Django project
56+
settings.SILENCED_SYSTEM_CHECKS = ['1_7.W001']
6457

6558

6659
def reload_settings():
@@ -85,23 +78,16 @@ def test_response_contains_expected_checks(self):
8578
request = RequestFactory().get('/')
8679
response = views.status(request)
8780

88-
if PYTHON_VERSION == 2:
89-
content = json.loads(response.content)
90-
self.assertItemsEqual(expected_checks, content.keys())
91-
else:
92-
content = json.loads(response.content.decode('utf-8'))
93-
self.assertCountEqual(expected_checks, content.keys())
81+
content = json.loads(response.content.decode('utf-8'))
82+
self.assertCountEqual(expected_checks, content.keys())
9483

9584
def test_check_database_handles_exception(self):
9685
response = checks._check_database('foo')
9786
self.assertFalse(response['foo']['ok'])
9887
self.assertEqual(response['foo']['error'], "The connection foo doesn't exist")
9988

10089
def test_check_cache_handles_exception(self):
101-
if django.VERSION < (1, 7):
102-
expected_error = "Could not find backend 'foo': Could not find backend 'foo': foo doesn't look like a module path"
103-
else:
104-
expected_error = "Could not find config for 'foo' in settings.CACHES"
90+
expected_error = "Could not find config for 'foo' in settings.CACHES"
10591

10692
response = checks._check_cache('foo')
10793
self.assertFalse(response['foo']['ok'])
@@ -114,12 +100,8 @@ def test_response_skipped_checks(self):
114100
})
115101
response = views.status(request)
116102

117-
if PYTHON_VERSION == 2:
118-
content = json.loads(response.content)
119-
self.assertItemsEqual(expected_checks, content.keys())
120-
else:
121-
content = json.loads(response.content.decode('utf-8'))
122-
self.assertCountEqual(expected_checks, content.keys())
103+
content = json.loads(response.content.decode('utf-8'))
104+
self.assertCountEqual(expected_checks, content.keys())
123105

124106
def test_response_is_404_for_checked_and_skipped_check(self):
125107
# This is a bit of a weird one, basically if you explicitly include and
@@ -141,12 +123,8 @@ def test_response_only_single_check(self, patched_check_databases):
141123
response = views.status(request)
142124
self.assertEqual(response.status_code, 200)
143125

144-
if PYTHON_VERSION == 2:
145-
content = json.loads(response.content)
146-
self.assertItemsEqual({'databases': []}, content)
147-
else:
148-
content = json.loads(response.content.decode('utf-8'))
149-
self.assertCountEqual({'databases': []}, content)
126+
content = json.loads(response.content.decode('utf-8'))
127+
self.assertCountEqual({'databases': []}, content)
150128

151129
def test_response_404_when_none_specified(self):
152130
request = RequestFactory().get('/', data={
@@ -155,12 +133,8 @@ def test_response_404_when_none_specified(self):
155133
response = views.status(request)
156134
self.assertEqual(response.status_code, 404)
157135

158-
if PYTHON_VERSION == 2:
159-
content = json.loads(response.content)
160-
self.assertItemsEqual({'message': 'No checks found', 'error': 404}, content)
161-
else:
162-
content = json.loads(response.content.decode('utf-8'))
163-
self.assertCountEqual({'message': 'No checks found', 'error': 404}, content)
136+
content = json.loads(response.content.decode('utf-8'))
137+
self.assertCountEqual({'message': 'No checks found', 'error': 404}, content)
164138

165139
@override_settings(WATCHMAN_TOKEN='ABCDE')
166140
@override_settings(WATCHMAN_AUTH_DECORATOR='watchman.decorators.token_required')

tox.ini

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
[tox]
22
envlist =
33
covclean,
4-
py27-dj111,
5-
py{35,36,37}-dj{111,20,21,22},
4+
py{36,37,38}-dj{22,30},
5+
py{35}-dj22,
66
coverage
77

88
[testenv]
99
setenv =
1010
PYTHONPATH = {toxinidir}:{toxinidir}/watchman
1111
commands = coverage run --parallel --source watchman runtests.py {posargs}
1212
deps =
13-
dj111: Django>=1.11,<2.0
14-
dj20: Django>=2.0,<2.1
15-
dj21: Django>=2.1,<2.2
1613
dj22: Django>=2.2,<2.3
14+
dj30: Django>=3.0,<3.1
1715
-r{toxinidir}/requirements-test.txt
1816

1917
[testenv:covclean]

watchman/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.18.0'
1+
__version__ = '1.0.0'

0 commit comments

Comments
 (0)