-
-
Notifications
You must be signed in to change notification settings - Fork 244
[deps] Upgrade Django 5.x and channels dependencies from openwisp-utils extras #1001
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
Changes from all commits
a72a8fc
f69e833
71ee123
98ffd3a
d6f7fc2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,6 @@ | |
|
|
||
| from openwisp_utils.tests import catch_signal | ||
|
|
||
| from ...tests.utils import TransactionTestMixin | ||
| from .. import settings as app_settings | ||
| from ..signals import config_modified, config_status_changed | ||
| from ..tasks import logger as task_logger | ||
|
|
@@ -356,7 +355,10 @@ def test_context_regression(self): | |
| template_qs = Template.objects.filter(type='vpn') | ||
| self.assertEqual(template_qs.count(), 1) | ||
| t = template_qs.first() | ||
| self.assertDictContainsSubset(_original_context, t.get_context()) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is removed in Python 3.12 |
||
| context = t.get_context() | ||
| # check all items from original context exist in template context | ||
| for key, value in _original_context.items(): | ||
| self.assertEqual(context.get(key), value) | ||
| self.assertEqual(app_settings.CONTEXT, _original_context) | ||
|
|
||
| with self.subTest( | ||
|
|
@@ -517,7 +519,6 @@ def test_regression_preventing_from_fixing_invalid_conf(self): | |
|
|
||
|
|
||
| class TestTemplateTransaction( | ||
| TransactionTestMixin, | ||
| CreateConfigTemplateMixin, | ||
| TestVpnX509Mixin, | ||
| TransactionTestCase, | ||
|
|
@@ -554,7 +555,7 @@ def test_config_status_modified_after_change(self): | |
| with catch_signal(config_status_changed) as handler: | ||
| t.config['interfaces'][0]['name'] = 'eth2' | ||
| t.full_clean() | ||
| with self.assertNumQueries(9): | ||
| with self.assertNumQueries(10): | ||
| t.save() | ||
| c.refresh_from_db() | ||
| handler.assert_not_called() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,3 +78,4 @@ def test_add_mobile(self): | |
|
|
||
|
|
||
| del TestConfigAdmin | ||
| del BaseTestAdminInline | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -577,7 +577,7 @@ def test_change_location_type_to_outdoor_api(self): | |
| self._create_floorplan(location=l1) | ||
| path = reverse('geo_api:detail_location', args=[l1.pk]) | ||
| data = {'type': 'outdoor'} | ||
| with self.assertNumQueries(8): | ||
| with self.assertNumQueries(9): | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The number of queries increased because of these changes openwisp/django-loci#157 |
||
| response = self.client.patch(path, data, content_type='application/json') | ||
| self.assertEqual(response.status_code, 200) | ||
| self.assertEqual(response.data['floorplan'], []) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,4 @@ | ||
| import django | ||
| from django.contrib.auth import get_user_model | ||
| from django.db import connections | ||
| from django.db.utils import DEFAULT_DB_ALIAS | ||
| from django.test.testcases import _AssertNumQueriesContext | ||
| from django.urls import reverse | ||
|
|
||
| from openwisp_users.tests.utils import TestMultitenantAdminMixin | ||
|
|
@@ -20,32 +16,3 @@ def _test_changelist_recover_deleted(self, app_label, model_label): | |
|
|
||
| def _login(self, username='admin', password='tester'): | ||
| self.client.force_login(user_model.objects.get(username=username)) | ||
|
|
||
|
|
||
| class _ManagementTransactionNumQueriesContext(_AssertNumQueriesContext): | ||
| def __exit__(self, exc_type, exc_value, traceback): | ||
| """ | ||
| Django 4.2 introduced support for logging transaction | ||
| management queries (BEGIN, COMMIT, and ROLLBACK). | ||
| This method increases the number of expected database | ||
| queries if COMMIT/ROLLBACK queries are found when | ||
| using Django 4.2 | ||
| """ | ||
| if exc_type is not None: | ||
| return | ||
| for query in self.captured_queries: | ||
| if django.VERSION > (4, 2) and 'COMMIT' in query['sql']: | ||
| self.num += 1 | ||
| super().__exit__(exc_type, exc_value, traceback) | ||
|
|
||
|
|
||
| class TransactionTestMixin(object): | ||
| def assertNumQueries(self, num, func=None, *args, using=DEFAULT_DB_ALIAS, **kwargs): | ||
| conn = connections[using] | ||
|
|
||
| context = _ManagementTransactionNumQueriesContext(self, num, conn) | ||
| if func is None: | ||
| return context | ||
|
|
||
| with context: | ||
| func(*args, **kwargs) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great, thanks! |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,15 @@ | ||
| from channels.auth import AuthMiddlewareStack | ||
| from channels.routing import ProtocolTypeRouter, URLRouter | ||
| from channels.security.websocket import AllowedHostsOriginValidator | ||
| from django.core.asgi import get_asgi_application | ||
|
|
||
| from openwisp_controller.routing import get_routes | ||
|
|
||
| application = ProtocolTypeRouter( | ||
| { | ||
| 'websocket': AllowedHostsOriginValidator( | ||
| AuthMiddlewareStack(URLRouter(get_routes())) | ||
| ) | ||
| ), | ||
| 'http': get_asgi_application(), | ||
nemesifier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| ) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is removed in Python 3.12