Skip to content

Commit de7811c

Browse files
authored
[deps] Upgraded to Django 5.x and channels 4 #245
* [deps] Added "channels" and "channels-test" extra requires * [deps] Added support for Django >=5.1,<5.3 and Python >=3.12, 3.14 #245 - Dropped support for Python < 3.9 - Dropped support for Django < 4.2 Closes #245
1 parent 72c5549 commit de7811c

File tree

8 files changed

+28
-19
lines changed

8 files changed

+28
-19
lines changed

.github/workflows/ci.yml

+14-3
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,24 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
python-version:
27-
- "3.8"
2827
- "3.9"
2928
- "3.10"
29+
- "3.11"
30+
- "3.12"
31+
- "3.13"
3032
django-version:
31-
- django~=3.2.0
32-
- django~=4.1.0
3333
- django~=4.2.0
34+
- django~=5.1.0
35+
- django~=5.2.0
36+
exclude:
37+
# Django 5.1+ requires Python >=3.10
38+
- python-version: "3.9"
39+
django-version: django~=5.1.0
40+
- python-version: "3.9"
41+
django-version: django~=5.2.0
42+
# Python 3.13 supported only in Django >=5.1.3
43+
- python-version: "3.13"
44+
django-version: django~=4.2.0
3445

3546
steps:
3647
- uses: actions/checkout@v4

openwisp_network_topology/consumers.py

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def connect(self):
4040

4141
def disconnect(self, close_code):
4242
self.close()
43-
pass
4443

4544
def send_topology_update(self, event):
4645
self.send(

openwisp_network_topology/tests/test_websockets.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,10 @@ async def _assert_connection_org_manager(self, client, view_perm=True, conn=True
5959
)
6060
t = await database_sync_to_async(self._create_topology)(organization=org)
6161
if view_perm:
62-
topology_view_permission = await database_sync_to_async(
63-
Permission.objects.get
64-
)(codename='view_topology')
65-
await database_sync_to_async(test_user.user_permissions.add)(
66-
topology_view_permission
62+
topology_view_permission = await Permission.objects.aget(
63+
codename='view_topology'
6764
)
65+
await test_user.user_permissions.aadd(topology_view_permission)
6866
await database_sync_to_async(client.force_login)(test_user)
6967
communicator = await self._get_communicator(client, t.pk)
7068
connected, _ = await communicator.connect()
@@ -134,7 +132,7 @@ async def test_node_topology_update(self, admin_user, admin_client):
134132
response = await communicator.receive_json_from()
135133
assert response['topology'] is not None
136134
assert response['topology'] == expected_response
137-
await database_sync_to_async(node.delete)()
135+
await node.adelete()
138136
expected_response = await database_sync_to_async(topo.json)()
139137
response = await communicator.receive_json_from()
140138
assert response['topology'] is not None
@@ -164,12 +162,12 @@ async def test_link_topology_update(self, admin_user, admin_client):
164162
assert response['topology'] == expected_response
165163
link.status = 'down'
166164
await database_sync_to_async(link.full_clean)()
167-
await database_sync_to_async(link.save)()
165+
await link.asave()
168166
expected_response = await database_sync_to_async(topo.json)()
169167
response = await communicator.receive_json_from()
170168
assert response['topology'] is not None
171169
assert response['topology'] == expected_response
172-
await database_sync_to_async(link.delete)()
170+
await link.adelete()
173171
expected_response = await database_sync_to_async(topo.json)()
174172
response = await communicator.receive_json_from()
175173
assert response['topology'] is not None
@@ -184,7 +182,7 @@ async def test_topology_properties_update(self, admin_user, admin_client):
184182
assert connected is True
185183
topo.name = 'test'
186184
await database_sync_to_async(topo.full_clean)()
187-
await database_sync_to_async(topo.save)()
185+
await topo.asave()
188186
expected_response = await database_sync_to_async(topo.json)()
189187
response = await communicator.receive_json_from()
190188
assert response['topology'] is not None

openwisp_network_topology/tests/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ def _create_link(self, **kwargs):
6060

6161

6262
class LoggingDisabledTestRunner(TimeLoggingTestRunner):
63-
def run_tests(self, test_labels, extra_tests=None, **kwargs):
63+
def run_tests(self, test_labels, **kwargs):
6464
# disable logging below CRITICAL while testing
6565
logging.disable(logging.CRITICAL)
66-
return super().run_tests(test_labels, extra_tests, **kwargs)
66+
return super().run_tests(test_labels, **kwargs)
6767

6868

6969
class UnpublishMixin(object):

requirements-test.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
responses~=0.25.7
2-
pytest-asyncio~=0.24.0
3-
pytest-django~=4.10.0
42
freezegun~=1.5.1
53
# Needed to test integrations
64
openwisp-monitoring @ https://github.com/openwisp/openwisp-monitoring/tarball/1.2
75
openwisp-controller @ https://github.com/openwisp/openwisp-controller/tarball/1.2
8-
openwisp-utils[qa,selenium] @ https://github.com/openwisp/openwisp-utils/tarball/1.2
6+
openwisp-utils[qa,selenium,channels-test] @ https://github.com/openwisp/openwisp-utils/tarball/1.2
97
redis~=5.2.1
108
django_redis~=5.4.0

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ openwisp-users @ https://github.com/openwisp/openwisp-users/tarball/1.2
22
netdiff @ https://github.com/openwisp/netdiff/tarball/1.2
33
jsonfield~=3.1.0
44
django-flat-json-widget~=0.3.1
5-
openwisp-utils[celery] @ https://github.com/openwisp/openwisp-utils/tarball/1.2
5+
openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/tarball/1.2

tests/openwisp2/asgi.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from channels.auth import AuthMiddlewareStack
22
from channels.routing import ProtocolTypeRouter, URLRouter
33
from django.conf import settings
4+
from django.core.asgi import get_asgi_application
45

56
if 'openwisp_controller.geo' in settings.INSTALLED_APPS:
67
from openwisp_controller.routing import get_routes as get_controller_routes
@@ -27,5 +28,6 @@ def get_controller_routes():
2728
+ get_controller_routes()
2829
)
2930
),
31+
'http': get_asgi_application(),
3032
}
3133
)

tests/openwisp2/settings.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
SECRET_KEY = '@q4z-^s=mv59#o=uutv4*m=h@)ik4%zp1)-k^_(!_7*x_&+ze$'
2121

2222
INSTALLED_APPS = [
23+
'daphne',
2324
'django.contrib.auth',
2425
'django.contrib.contenttypes',
2526
'django.contrib.sessions',

0 commit comments

Comments
 (0)